Commit ee6060b
authored
Fix search not scrolling to result past view (#19571)
## Summary of the Pull Request
Fixes a bug where search would not scroll to results just below the
viewport.
This was caused by code intended to scroll the search result in such a
way that it isn't covered by the search box. The scroll offset is
calculated in `TermControl::_calculateSearchScrollOffset()` then handed
down in the `SearchRequest` when conducting a search. This would get to
`Terminal::ScrollToSearchHighlight()` where the offset is applied to the
search result's position so that we would scroll to the adjusted
position.
The adjustment was overly aggressive in that it would apply it to both
"start" and "end". In reality, we don't need to apply it to "end"
because it wouldn't be covered by the search box (we only scroll to end
if it's past the end of the current view anyways).
The fix applies the adjustment only to "start" and only does so if it's
actually in the first few rows that would be covered by the search box.
That unveiled another bug where `Terminal::_ScrollToPoints()` would also
be too aggressive about scrolling the "end" into view. In some testing,
it would generally end up scrolling to the end of the buffer. To fix
this cascading bug, I just had `_ScrollToPoints()` just call
`Terminal::_ScrollToPoint()` (singular, not plural) which is
consistently used throughout the Terminal code for selection (so it's
battle tested).
`_ScrollToPoints()` was kept since it's still used for accessibility
when selecting a new region to keep the new selection in view. It's also
just a nice wrapper that ensures a range is visible (or at least as much
as it could be).
## References and Relevant Issues
Scroll offset was added in #17516
## Validation Steps Performed
✅ search results that would be covered by the search box are still
adjusted
✅ search results that are past the end of the view become visible
✅ UIA still selects properly and brings the selection into view
## PR Checklist
Duncan reported this bug internally, but there doesn't seem to be one on
the repo.1 parent 81cdb07 commit ee6060b
File tree
2 files changed
+11
-20
lines changed- src/cascadia/TerminalCore
2 files changed
+11
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1297 | 1297 | | |
1298 | 1298 | | |
1299 | 1299 | | |
1300 | | - | |
1301 | | - | |
1302 | | - | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1303 | 1309 | | |
1304 | 1310 | | |
1305 | 1311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | 155 | | |
157 | 156 | | |
158 | | - | |
159 | | - | |
160 | | - | |
| 157 | + | |
161 | 158 | | |
162 | 159 | | |
163 | 160 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
| 161 | + | |
170 | 162 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | 163 | | |
179 | 164 | | |
180 | 165 | | |
| |||
0 commit comments