Skip to content

Clear the cached selection when highlighting re-shapes lines - #3513

Open
trougnouf wants to merge 1 commit into
iced-rs:masterfrom
trougnouf:fix/stale-caret-after-highlight
Open

trougnouf wants to merge 1 commit into
iced-rs:masterfrom
trougnouf:fix/stale-caret-after-highlight

Conversation

@trougnouf

@trougnouf trougnouf commented Oct 18, 2026 •

Copy link
Copy Markdown

Editor::highlight() re-shapes lines with new attributes (e.g. bold) via shape_as_needed, but the cached selection still holds the caret position computed from the previous, unstyled layout, so the caret is drawn at the wrong x-offset until the next perform() clears the cache. Clear it after re-shaping, as the other mutators (perform, move_to, update) already do.

This fixes https://git.disroot.org/trougnouf/cfait/issues/24 . I've only tested with Iced 0.14.0 (where I backported the fix) but the behavior seems identical. (I can create a self-contained test on master if needed.)

Editor::highlight() re-shapes lines with new attributes (e.g. bold) via shape_as_needed, but the cached selection still holds the caret position computed from the previous, unstyled layout, so the caret is drawn at the wrong x-offset until the next perform() clears the cache. Clear it after re-shaping, as the other mutators (perform, move_to, update) already do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant