[Conhost] Fix off-by-1 error when copying and coloring selections#19259
Merged
carlos-zamora merged 1 commit intomainfrom Aug 20, 2025
Merged
[Conhost] Fix off-by-1 error when copying and coloring selections#19259carlos-zamora merged 1 commit intomainfrom
carlos-zamora merged 1 commit intomainfrom
Conversation
lhecker
approved these changes
Aug 20, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::GetTextRectsandGetSelectionSpans(). BothSelection::ColorSelection()were updated to userectoverinclusive_rectto 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