Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
chore: Use aho-corasick 1.1 in direct dependencies (#2983)
Piotr Osiewicz616d328f3c34
diff --git a/Cargo.lock b/Cargo.lockindex b77ff20af3c..c620cb2b881 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -79,18 +79,9 @@ dependencies = [[[package]]name = "aho-corasick"-version = "0.7.20"-source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"-dependencies = [- "memchr",-]--[[package]]-name = "aho-corasick"-version = "1.0.4"+version = "1.1.0"source = "registry+https://github.com/rust-lang/crates.io-index"-checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a"+checksum = "0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0"dependencies = ["memchr",]@@ -2332,7 +2323,7 @@ checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555"name = "editor"version = "0.1.0"dependencies = [- "aho-corasick 0.7.20",+ "aho-corasick","anyhow","client","clock",@@ -3080,7 +3071,7 @@ version = "0.4.13"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d"dependencies = [- "aho-corasick 1.0.4",+ "aho-corasick","bstr","fnv","log",@@ -5462,7 +5453,7 @@ dependencies = [name = "project"version = "0.1.0"dependencies = [- "aho-corasick 0.7.20",+ "aho-corasick","anyhow","async-trait","backtrace",@@ -5972,7 +5963,7 @@ version = "1.9.3"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a"dependencies = [- "aho-corasick 1.0.4",+ "aho-corasick","memchr","regex-automata 0.3.6","regex-syntax 0.7.4",@@ -5993,7 +5984,7 @@ version = "0.3.6"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69"dependencies = [- "aho-corasick 1.0.4",+ "aho-corasick","memchr","regex-syntax 0.7.4",]diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rsindex a9f4a31eb7c..10d6baec190 100644--- a/crates/collab/src/tests/integration_tests.rs+++ b/crates/collab/src/tests/integration_tests.rs@@ -4825,7 +4825,7 @@ async fn test_project_search(let mut results = HashMap::default();let mut search_rx = project_b.update(cx_b, |project, cx| {project.search(- SearchQuery::text("world", false, false, Vec::new(), Vec::new()),+ SearchQuery::text("world", false, false, Vec::new(), Vec::new()).unwrap(),cx,)});diff --git a/crates/collab/src/tests/random_project_collaboration_tests.rs b/crates/collab/src/tests/random_project_collaboration_tests.rsindex 7570768249c..6f9513c3253 100644--- a/crates/collab/src/tests/random_project_collaboration_tests.rs+++ b/crates/collab/src/tests/random_project_collaboration_tests.rs@@ -869,7 +869,7 @@ impl RandomizedTest for ProjectCollaborationTest {let mut search = project.update(cx, |project, cx| {project.search(- SearchQuery::text(query, false, false, Vec::new(), Vec::new()),+ SearchQuery::text(query, false, false, Vec::new(), Vec::new()).unwrap(),cx,)});diff --git a/crates/editor/Cargo.toml b/crates/editor/Cargo.tomlindex 2fdeee56c18..b0f8323a76b 100644--- a/crates/editor/Cargo.toml+++ b/crates/editor/Cargo.toml@@ -45,7 +45,7 @@ util = { path = "../util" }sqlez = { path = "../sqlez" }workspace = { path = "../workspace" }-aho-corasick = "0.7"+aho-corasick = "1.1"anyhow.workspace = trueconvert_case = "0.6.0"futures.workspace = truediff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex b36cf9f71da..8c30859841f 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -5936,7 +5936,7 @@ impl Editor {}}- pub fn select_next(&mut self, action: &SelectNext, cx: &mut ViewContext<Self>) {+ pub fn select_next(&mut self, action: &SelectNext, cx: &mut ViewContext<Self>) -> Result<()> {self.push_to_selection_history();let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));let buffer = &display_map.buffer_snapshot;@@ -6005,7 +6005,7 @@ impl Editor {.text_for_range(selection.start..selection.end).collect::<String>();let select_state = SelectNextState {- query: AhoCorasick::new_auto_configured(&[query]),+ query: AhoCorasick::new(&[query])?,wordwise: true,done: false,};@@ -6019,16 +6019,21 @@ impl Editor {.text_for_range(selection.start..selection.end).collect::<String>();self.select_next_state = Some(SelectNextState {- query: AhoCorasick::new_auto_configured(&[query]),+ query: AhoCorasick::new(&[query])?,wordwise: false,done: false,});- self.select_next(action, cx);+ self.select_next(action, cx)?;}}+ Ok(())}- pub fn select_previous(&mut self, action: &SelectPrevious, cx: &mut ViewContext<Self>) {+ pub fn select_previous(+ &mut self,+ action: &SelectPrevious,+ cx: &mut ViewContext<Self>,+ ) -> Result<()> {self.push_to_selection_history();let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));let buffer = &display_map.buffer_snapshot;@@ -6099,7 +6104,7 @@ impl Editor {.collect::<String>();let query = query.chars().rev().collect::<String>();let select_state = SelectNextState {- query: AhoCorasick::new_auto_configured(&[query]),+ query: AhoCorasick::new(&[query])?,wordwise: true,done: false,};@@ -6114,13 +6119,14 @@ impl Editor {.collect::<String>();let query = query.chars().rev().collect::<String>();self.select_prev_state = Some(SelectNextState {- query: AhoCorasick::new_auto_configured(&[query]),+ query: AhoCorasick::new(&[query])?,wordwise: false,done: false,});- self.select_previous(action, cx);+ self.select_previous(action, cx)?;}}+ Ok(())}pub fn toggle_comments(&mut self, action: &ToggleComments, cx: &mut ViewContext<Self>) {diff --git a/crates/editor/src/editor_tests.rs b/crates/editor/src/editor_tests.rsindex f11639a7701..7acf0c652f1 100644--- a/crates/editor/src/editor_tests.rs+++ b/crates/editor/src/editor_tests.rs@@ -3669,10 +3669,12 @@ async fn test_select_next(cx: &mut gpui::TestAppContext) {let mut cx = EditorTestContext::new(cx).await;cx.set_state("abc\nˇabc abc\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));+ cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))+ .unwrap();cx.assert_editor_state("abc\n«abcˇ» abc\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));+ cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))+ .unwrap();cx.assert_editor_state("abc\n«abcˇ» «abcˇ»\ndefabc\nabc");cx.update_editor(|view, cx| view.undo_selection(&UndoSelection, cx));@@ -3681,10 +3683,12 @@ async fn test_select_next(cx: &mut gpui::TestAppContext) {cx.update_editor(|view, cx| view.redo_selection(&RedoSelection, cx));cx.assert_editor_state("abc\n«abcˇ» «abcˇ»\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));+ cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))+ .unwrap();cx.assert_editor_state("abc\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");- cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));+ cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");}@@ -3696,10 +3700,12 @@ async fn test_select_previous(cx: &mut gpui::TestAppContext) {let mut cx = EditorTestContext::new(cx).await;cx.set_state("abc\nˇabc abc\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("abc\n«abcˇ» abc\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«abcˇ» abc\ndefabc\nabc");cx.update_editor(|view, cx| view.undo_selection(&UndoSelection, cx));@@ -3708,10 +3714,12 @@ async fn test_select_previous(cx: &mut gpui::TestAppContext) {cx.update_editor(|view, cx| view.redo_selection(&RedoSelection, cx));cx.assert_editor_state("«abcˇ»\n«abcˇ» abc\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«abcˇ» abc\ndefabc\n«abcˇ»");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");}{@@ -3719,10 +3727,12 @@ async fn test_select_previous(cx: &mut gpui::TestAppContext) {let mut cx = EditorTestContext::new(cx).await;cx.set_state("abc\n«ˇabc» abc\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndefabc\nabc");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndefabc\n«abcˇ»");cx.update_editor(|view, cx| view.undo_selection(&UndoSelection, cx));@@ -3731,10 +3741,12 @@ async fn test_select_previous(cx: &mut gpui::TestAppContext) {cx.update_editor(|view, cx| view.redo_selection(&RedoSelection, cx));cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndefabc\n«abcˇ»");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndef«abcˇ»\n«abcˇ»");- cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));+ cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))+ .unwrap();cx.assert_editor_state("«abcˇ»\n«ˇabc» «abcˇ»\ndef«abcˇ»\n«abcˇ»");}}diff --git a/crates/project/Cargo.toml b/crates/project/Cargo.tomlindex bfe5f89f682..0dc76ed54ab 100644--- a/crates/project/Cargo.toml+++ b/crates/project/Cargo.toml@@ -37,7 +37,7 @@ sum_tree = { path = "../sum_tree" }terminal = { path = "../terminal" }util = { path = "../util" }-aho-corasick = "0.7"+aho-corasick = "1.1"anyhow.workspace = trueasync-trait.workspace = truebacktrace = "0.3"diff --git a/crates/project/src/project_tests.rs b/crates/project/src/project_tests.rsindex b6adb371e10..540915f354a 100644--- a/crates/project/src/project_tests.rs+++ b/crates/project/src/project_tests.rs@@ -3598,7 +3598,7 @@ async fn test_search(cx: &mut gpui::TestAppContext) {assert_eq!(search(&project,- SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()),+ SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()).unwrap(),cx).await@@ -3623,7 +3623,7 @@ async fn test_search(cx: &mut gpui::TestAppContext) {assert_eq!(search(&project,- SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()),+ SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()).unwrap(),cx).await@@ -3664,7 +3664,8 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {true,vec![PathMatcher::new("*.odd").unwrap()],Vec::new()- ),+ )+ .unwrap(),cx).await@@ -3682,7 +3683,8 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {true,vec![PathMatcher::new("*.rs").unwrap()],Vec::new()- ),+ )+ .unwrap(),cx).await@@ -3706,7 +3708,7 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {PathMatcher::new("*.odd").unwrap(),],Vec::new()- ),+ ).unwrap(),cx).await@@ -3731,7 +3733,7 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {PathMatcher::new("*.odd").unwrap(),],Vec::new()- ),+ ).unwrap(),cx).await@@ -3774,7 +3776,8 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {true,Vec::new(),vec![PathMatcher::new("*.odd").unwrap()],- ),+ )+ .unwrap(),cx).await@@ -3797,7 +3800,8 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {true,Vec::new(),vec![PathMatcher::new("*.rs").unwrap()],- ),+ )+ .unwrap(),cx).await@@ -3821,7 +3825,7 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {PathMatcher::new("*.ts").unwrap(),PathMatcher::new("*.odd").unwrap(),],- ),+ ).unwrap(),cx).await@@ -3846,7 +3850,7 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {PathMatcher::new("*.ts").unwrap(),PathMatcher::new("*.odd").unwrap(),],- ),+ ).unwrap(),cx).await@@ -3883,7 +3887,8 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContextrue,vec![PathMatcher::new("*.odd").unwrap()],vec![PathMatcher::new("*.odd").unwrap()],- ),+ )+ .unwrap(),cx).await@@ -3901,7 +3906,7 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContextrue,vec![PathMatcher::new("*.ts").unwrap()],vec![PathMatcher::new("*.ts").unwrap()],- ),+ ).unwrap(),cx).await@@ -3925,7 +3930,8 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContexPathMatcher::new("*.ts").unwrap(),PathMatcher::new("*.odd").unwrap()],- ),+ )+ .unwrap(),cx).await@@ -3949,7 +3955,8 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContexPathMatcher::new("*.rs").unwrap(),PathMatcher::new("*.odd").unwrap()],- ),+ )+ .unwrap(),cx).awaitdiff --git a/crates/project/src/search.rs b/crates/project/src/search.rsindex bf811587013..663ad461235 100644--- a/crates/project/src/search.rs+++ b/crates/project/src/search.rs@@ -35,7 +35,7 @@ impl SearchInputs {#[derive(Clone, Debug)]pub enum SearchQuery {Text {- search: Arc<AhoCorasick<usize>>,+ search: Arc<AhoCorasick>,replacement: Option<String>,whole_word: bool,case_sensitive: bool,@@ -84,24 +84,23 @@ impl SearchQuery {case_sensitive: bool,files_to_include: Vec<PathMatcher>,files_to_exclude: Vec<PathMatcher>,- ) -> Self {+ ) -> Result<Self> {let query = query.to_string();let search = AhoCorasickBuilder::new()- .auto_configure(&[&query]).ascii_case_insensitive(!case_sensitive)- .build(&[&query]);+ .build(&[&query])?;let inner = SearchInputs {query: query.into(),files_to_exclude,files_to_include,};- Self::Text {+ Ok(Self::Text {search: Arc::new(search),replacement: None,whole_word,case_sensitive,inner,- }+ })}pub fn regex(@@ -151,13 +150,13 @@ impl SearchQuery {deserialize_path_matches(&message.files_to_exclude)?,)} else {- Ok(Self::text(+ Self::text(message.query,message.whole_word,message.case_sensitive,deserialize_path_matches(&message.files_to_include)?,deserialize_path_matches(&message.files_to_exclude)?,- ))+ )}}pub fn with_replacement(mut self, new_replacement: Option<String>) -> Self {diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rsindex bf92c2b72ef..5fc0854b811 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -783,14 +783,21 @@ impl BufferSearchBar {}}} else {- SearchQuery::text(+ match SearchQuery::text(query,self.search_options.contains(SearchOptions::WHOLE_WORD),self.search_options.contains(SearchOptions::CASE_SENSITIVE),Vec::new(),Vec::new(),- )- .with_replacement(Some(self.replacement(cx)).filter(|s| !s.is_empty()))+ ) {+ Ok(query) => query+ .with_replacement(Some(self.replacement(cx)).filter(|s| !s.is_empty())),+ Err(_) => {+ self.query_contains_error = true;+ cx.notify();+ return done_rx;+ }+ }}.into();self.active_search = Some(query.clone());diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rsindex 240928d4e05..19442191172 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -1050,13 +1050,23 @@ impl ProjectSearchView {}}}- _ => Some(SearchQuery::text(+ _ => match SearchQuery::text(text,self.search_options.contains(SearchOptions::WHOLE_WORD),self.search_options.contains(SearchOptions::CASE_SENSITIVE),included_files,excluded_files,- )),+ ) {+ Ok(query) => {+ self.panels_with_errors.remove(&InputPanel::Query);+ Some(query)+ }+ Err(_e) => {+ self.panels_with_errors.insert(InputPanel::Query);+ cx.notify();+ None+ }+ },}}