Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
project_search: Guard replace_next match lookup (#48327)
Xiaobo Liubb2ee343b4f0
diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rsindex ddb7e987aaf..45b72ed27f3 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -728,10 +728,11 @@ impl ProjectSearchView {if let Some(query) = query {let query = query.with_replacement(self.replacement(cx));- // TODO: Do we need the clone here?- let mat = self.entity.read(cx).match_ranges[active_index].clone();+ let mat = self.entity.read(cx).match_ranges.get(active_index).cloned();self.results_editor.update(cx, |editor, cx| {- editor.replace(&mat, &query, window, cx);+ if let Some(mat) = mat.as_ref() {+ editor.replace(mat, &query, window, cx);+ }});self.select_match(Direction::Next, window, cx)}