search: Fix buffer search history navigation (#37924)

Closes #36109 

Adds an additional option to `search` and `update_matches` to specify
whether the update should affect the search history.

Release Notes:

- Fix navigating buffer search history
This commit is contained in:
tidely
2025-09-11 14:55:14 +02:00
committed by GitHub
parent c4e8fe1fb7
commit 4db19a3a96
4 changed files with 78 additions and 59 deletions
+1
View File
@@ -1585,6 +1585,7 @@ impl OnMatchingLines {
let _ = search_bar.search(
&last_pattern,
Some(SearchOptions::REGEX | SearchOptions::CASE_SENSITIVE),
false,
window,
cx,
);
+5 -5
View File
@@ -360,12 +360,12 @@ impl Vim {
.query_suggestion(window, cx)
.or_else(|| cursor_word)
else {
drop(search_bar.search("", None, window, cx));
drop(search_bar.search("", None, false, window, cx));
return None;
};
let query = regex::escape(&query);
Some(search_bar.search(&query, Some(options), window, cx))
Some(search_bar.search(&query, Some(options), true, window, cx))
});
let Some(search) = search else { return false };
@@ -425,7 +425,7 @@ impl Vim {
);
}
Some(search_bar.search(&query, Some(options), window, cx))
Some(search_bar.search(&query, Some(options), true, window, cx))
});
let Some(search) = search else { return };
let search_bar = search_bar.downgrade();
@@ -509,7 +509,7 @@ impl Vim {
if replacement.flag_c {
search_bar.focus_replace(window, cx);
}
Some(search_bar.search(&search, Some(options), window, cx))
Some(search_bar.search(&search, Some(options), true, window, cx))
});
if replacement.flag_n {
self.move_cursor(
@@ -534,7 +534,7 @@ impl Vim {
search_bar.select_last_match(window, cx);
search_bar.replace_all(&Default::default(), window, cx);
editor.update(cx, |editor, cx| editor.clear_search_within_ranges(cx));
let _ = search_bar.search(&search_bar.query(cx), None, window, cx);
let _ = search_bar.search(&search_bar.query(cx), None, false, window, cx);
vim.update(cx, |vim, cx| {
vim.move_cursor(
Motion::StartOfLine {