terminal: Fix not able to select text during continuous output (#37395)

Closes #37211

Regressed in https://github.com/zed-industries/zed/pull/33305

Every time the terminal updates, we emit
`SearchEvent::MatchesInvalidated` to trigger a re-run of the buffer
search, which calls `clear_matches` to drop stale results.
https://github.com/zed-industries/zed/pull/33305 PR also cleared the
selection when clearing matches, which caused this issue. We could fix
it by only clearing matches and selection when they’re non-empty, but
it’s better to not clear the selection at all. This matches how the
editor behaves and keeps it consistent. This PR reverts that part of
code.


Release Notes:

- Fixed an issue where text selection was lost during continuous
terminal output.
This commit is contained in:
Smit Barmase
2025-09-03 03:00:09 +05:30
committed by GitHub
parent 5e01fb8f1c
commit 6dcae2711d
2 changed files with 1 additions and 6 deletions
-5
View File
@@ -1141,11 +1141,6 @@ impl Terminal {
}
}
pub fn clear_matches(&mut self) {
self.matches.clear();
self.set_selection(None);
}
pub fn select_matches(&mut self, matches: &[RangeInclusive<AlacPoint>]) {
let matches_to_select = self
.matches
+1 -1
View File
@@ -1523,7 +1523,7 @@ impl SearchableItem for TerminalView {
/// Clear stored matches
fn clear_matches(&mut self, _window: &mut Window, cx: &mut Context<Self>) {
self.terminal().update(cx, |term, _| term.clear_matches())
self.terminal().update(cx, |term, _| term.matches.clear())
}
/// Store matches returned from find_matches somewhere for rendering