Skip to content

Fix: CFAttributedString SetAttributes replaces attributes when clearing others - #150

Open
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix-cfattributedstring-clear-attributes
Open

Fix: CFAttributedString SetAttributes replaces attributes when clearing others#150
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix-cfattributedstring-clear-attributes

Conversation

@DTW-Thalion

@DTW-Thalion DTW-Thalion commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

CFAttributedStringSetAttributes with clearOtherAttributes set, when the range begins at an existing attribute boundary, went through ReplaceAttributesAtIndex. That function re-cached the existing attributes and ignored its replacement argument, so the old attributes were kept instead of being replaced by the new ones.

Pass the replacement dictionary to the cache.

The test set_clear.m sets an attribute over a run, then sets a different attribute over the same range with clearOtherAttributes true; it fails before this change (the first attribute survives) and passes after. Verified against Apple CoreFoundation.

Related

Part of the CFAttributedString series. #152 (substring, attribute removal and replacement) depends on this and on #151.

@DTW-Thalion
DTW-Thalion force-pushed the fix-cfattributedstring-clear-attributes branch from 93c38e3 to ee74cc1 Compare July 24, 2026 15:22
@DTW-Thalion DTW-Thalion reopened this Jul 24, 2026
@DTW-Thalion DTW-Thalion reopened this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant