Skip to content

Fix dangling search selection using viewport pos#19603

Merged
DHowett merged 3 commits intomainfrom
dev/cazamor/sln/search-selects-wrong
Dec 2, 2025
Merged

Fix dangling search selection using viewport pos#19603
DHowett merged 3 commits intomainfrom
dev/cazamor/sln/search-selects-wrong

Conversation

@carlos-zamora
Copy link
Member

Summary of the Pull Request

Fixes a bug where the dangling selection from a search would be applied to the wrong position. Specifically, the issue is that SetSelectionAnchor() and SetSelectionEnd() expect viewport positions whereas the searcher outputs buffer positions.

This PR simply applies the scroll offset to the search result before calling the functions.

In a separate iteration, I changed the functions to allow for viewport-relative vs buffer-relative positions. However, that ended up feeling a bit odd because this is the only scenario where the functions were receiving buffer-relative positions. I chose this approach instead because it's smaller/cleaner, even though we convert to viewport-relative before the call just to change it to buffer-relative in the function.

Bug introduced in #19550

Validation Steps Performed

The correct region is selected in the following scenarios:
✅ no scrollback
✅ with scrollback, at bottom
✅ with scrollback, not at bottom (selection isn't scrolled to, but I think that's ok. Can be fixed easily if requested)
✅ alt buffer

@DHowett DHowett merged commit 7f37fdd into main Dec 2, 2025
17 of 19 checks passed
@carlos-zamora carlos-zamora deleted the dev/cazamor/sln/search-selects-wrong branch December 3, 2025 00:05
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.

2 participants