Skip to content

Conversation

@carlos-zamora
Copy link
Member

Summary of the Pull Request

Fixes a bug where copying and coloring selected text would be off by one. This was introduced in #18106 when selection was updated to be stored as an exclusive range. Selection::_RegenerateSelectionSpans() was updated then, but copying text and coloring selection didn't rely on selection spans.

Copying text relies on GetSelectionAnchors(). This function has now been updated to increment the bottom-right point of the selection. This way, GetTextSpans() operates on the expected exclusive range.

Coloring selection relies on TextBuffer::SearchText(), TextBuffer::GetTextRects and GetSelectionSpans(). Both Selection::ColorSelection() were updated to use rect over inclusive_rect to emphasize that they are exclusive ranges. Converting between the two improves clarity and fixes the bug.

References and Relevant Issues

Introduced in #18106

Validation Steps Performed

Copying text works in the following scenarios:
✅ single line, left-to-right and right-to-left
✅ multi-line, diagonal directions
✅ block selection

Coloring text works in the following scenarios:
✅ctrl+# --> color instance
✅ctrl+shift+# --> color all instances

Closes #19053

@carlos-zamora carlos-zamora merged commit 642a2aa into main Aug 20, 2025
19 checks passed
@carlos-zamora carlos-zamora deleted the dev/cazamor/bugfix/conhost-selection-off-by-1 branch August 20, 2025 17:43
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.

conhost: selecting text selects one character less (off by one)

3 participants