Skip to content

Commit 616d328

Browse files
authored
chore: Use aho-corasick 1.1 in direct dependencies (#2983)
Nothing too fancy, we've depended indirectly on 1.0/1.1 already, so this is essentially bookkeeping. Release Notes: - N/A
1 parent 5c22e40 commit 616d328

11 files changed

+99
-67
lines changed

Cargo.lock

Lines changed: 7 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/collab/src/tests/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4825,7 +4825,7 @@ async fn test_project_search(
48254825
let mut results = HashMap::default();
48264826
let mut search_rx = project_b.update(cx_b, |project, cx| {
48274827
project.search(
4828-
SearchQuery::text("world", false, false, Vec::new(), Vec::new()),
4828+
SearchQuery::text("world", false, false, Vec::new(), Vec::new()).unwrap(),
48294829
cx,
48304830
)
48314831
});

crates/collab/src/tests/random_project_collaboration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ impl RandomizedTest for ProjectCollaborationTest {
869869

870870
let mut search = project.update(cx, |project, cx| {
871871
project.search(
872-
SearchQuery::text(query, false, false, Vec::new(), Vec::new()),
872+
SearchQuery::text(query, false, false, Vec::new(), Vec::new()).unwrap(),
873873
cx,
874874
)
875875
});

crates/editor/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ util = { path = "../util" }
4545
sqlez = { path = "../sqlez" }
4646
workspace = { path = "../workspace" }
4747

48-
aho-corasick = "0.7"
48+
aho-corasick = "1.1"
4949
anyhow.workspace = true
5050
convert_case = "0.6.0"
5151
futures.workspace = true

crates/editor/src/editor.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5936,7 +5936,7 @@ impl Editor {
59365936
}
59375937
}
59385938

5939-
pub fn select_next(&mut self, action: &SelectNext, cx: &mut ViewContext<Self>) {
5939+
pub fn select_next(&mut self, action: &SelectNext, cx: &mut ViewContext<Self>) -> Result<()> {
59405940
self.push_to_selection_history();
59415941
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
59425942
let buffer = &display_map.buffer_snapshot;
@@ -6005,7 +6005,7 @@ impl Editor {
60056005
.text_for_range(selection.start..selection.end)
60066006
.collect::<String>();
60076007
let select_state = SelectNextState {
6008-
query: AhoCorasick::new_auto_configured(&[query]),
6008+
query: AhoCorasick::new(&[query])?,
60096009
wordwise: true,
60106010
done: false,
60116011
};
@@ -6019,16 +6019,21 @@ impl Editor {
60196019
.text_for_range(selection.start..selection.end)
60206020
.collect::<String>();
60216021
self.select_next_state = Some(SelectNextState {
6022-
query: AhoCorasick::new_auto_configured(&[query]),
6022+
query: AhoCorasick::new(&[query])?,
60236023
wordwise: false,
60246024
done: false,
60256025
});
6026-
self.select_next(action, cx);
6026+
self.select_next(action, cx)?;
60276027
}
60286028
}
6029+
Ok(())
60296030
}
60306031

6031-
pub fn select_previous(&mut self, action: &SelectPrevious, cx: &mut ViewContext<Self>) {
6032+
pub fn select_previous(
6033+
&mut self,
6034+
action: &SelectPrevious,
6035+
cx: &mut ViewContext<Self>,
6036+
) -> Result<()> {
60326037
self.push_to_selection_history();
60336038
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
60346039
let buffer = &display_map.buffer_snapshot;
@@ -6099,7 +6104,7 @@ impl Editor {
60996104
.collect::<String>();
61006105
let query = query.chars().rev().collect::<String>();
61016106
let select_state = SelectNextState {
6102-
query: AhoCorasick::new_auto_configured(&[query]),
6107+
query: AhoCorasick::new(&[query])?,
61036108
wordwise: true,
61046109
done: false,
61056110
};
@@ -6114,13 +6119,14 @@ impl Editor {
61146119
.collect::<String>();
61156120
let query = query.chars().rev().collect::<String>();
61166121
self.select_prev_state = Some(SelectNextState {
6117-
query: AhoCorasick::new_auto_configured(&[query]),
6122+
query: AhoCorasick::new(&[query])?,
61186123
wordwise: false,
61196124
done: false,
61206125
});
6121-
self.select_previous(action, cx);
6126+
self.select_previous(action, cx)?;
61226127
}
61236128
}
6129+
Ok(())
61246130
}
61256131

61266132
pub fn toggle_comments(&mut self, action: &ToggleComments, cx: &mut ViewContext<Self>) {

crates/editor/src/editor_tests.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3669,10 +3669,12 @@ async fn test_select_next(cx: &mut gpui::TestAppContext) {
36693669
let mut cx = EditorTestContext::new(cx).await;
36703670
cx.set_state("abc\nˇabc abc\ndefabc\nabc");
36713671

3672-
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));
3672+
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))
3673+
.unwrap();
36733674
cx.assert_editor_state("abc\n«abcˇ» abc\ndefabc\nabc");
36743675

3675-
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));
3676+
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))
3677+
.unwrap();
36763678
cx.assert_editor_state("abc\n«abcˇ» «abcˇ»\ndefabc\nabc");
36773679

36783680
cx.update_editor(|view, cx| view.undo_selection(&UndoSelection, cx));
@@ -3681,10 +3683,12 @@ async fn test_select_next(cx: &mut gpui::TestAppContext) {
36813683
cx.update_editor(|view, cx| view.redo_selection(&RedoSelection, cx));
36823684
cx.assert_editor_state("abc\n«abcˇ» «abcˇ»\ndefabc\nabc");
36833685

3684-
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));
3686+
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))
3687+
.unwrap();
36853688
cx.assert_editor_state("abc\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");
36863689

3687-
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx));
3690+
cx.update_editor(|e, cx| e.select_next(&SelectNext::default(), cx))
3691+
.unwrap();
36883692
cx.assert_editor_state("«abcˇ»\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");
36893693
}
36903694

@@ -3696,10 +3700,12 @@ async fn test_select_previous(cx: &mut gpui::TestAppContext) {
36963700
let mut cx = EditorTestContext::new(cx).await;
36973701
cx.set_state("abc\nˇabc abc\ndefabc\nabc");
36983702

3699-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3703+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3704+
.unwrap();
37003705
cx.assert_editor_state("abc\n«abcˇ» abc\ndefabc\nabc");
37013706

3702-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3707+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3708+
.unwrap();
37033709
cx.assert_editor_state("«abcˇ»\n«abcˇ» abc\ndefabc\nabc");
37043710

37053711
cx.update_editor(|view, cx| view.undo_selection(&UndoSelection, cx));
@@ -3708,21 +3714,25 @@ async fn test_select_previous(cx: &mut gpui::TestAppContext) {
37083714
cx.update_editor(|view, cx| view.redo_selection(&RedoSelection, cx));
37093715
cx.assert_editor_state("«abcˇ»\n«abcˇ» abc\ndefabc\nabc");
37103716

3711-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3717+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3718+
.unwrap();
37123719
cx.assert_editor_state("«abcˇ»\n«abcˇ» abc\ndefabc\n«abcˇ»");
37133720

3714-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3721+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3722+
.unwrap();
37153723
cx.assert_editor_state("«abcˇ»\n«abcˇ» «abcˇ»\ndefabc\n«abcˇ»");
37163724
}
37173725
{
37183726
// `Select previous` with a selection
37193727
let mut cx = EditorTestContext::new(cx).await;
37203728
cx.set_state("abc\n«ˇabc» abc\ndefabc\nabc");
37213729

3722-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3730+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3731+
.unwrap();
37233732
cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndefabc\nabc");
37243733

3725-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3734+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3735+
.unwrap();
37263736
cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndefabc\n«abcˇ»");
37273737

37283738
cx.update_editor(|view, cx| view.undo_selection(&UndoSelection, cx));
@@ -3731,10 +3741,12 @@ async fn test_select_previous(cx: &mut gpui::TestAppContext) {
37313741
cx.update_editor(|view, cx| view.redo_selection(&RedoSelection, cx));
37323742
cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndefabc\n«abcˇ»");
37333743

3734-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3744+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3745+
.unwrap();
37353746
cx.assert_editor_state("«abcˇ»\n«ˇabc» abc\ndef«abcˇ»\n«abcˇ»");
37363747

3737-
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx));
3748+
cx.update_editor(|e, cx| e.select_previous(&SelectPrevious::default(), cx))
3749+
.unwrap();
37383750
cx.assert_editor_state("«abcˇ»\n«ˇabc» «abcˇ»\ndef«abcˇ»\n«abcˇ»");
37393751
}
37403752
}

crates/project/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ sum_tree = { path = "../sum_tree" }
3737
terminal = { path = "../terminal" }
3838
util = { path = "../util" }
3939

40-
aho-corasick = "0.7"
40+
aho-corasick = "1.1"
4141
anyhow.workspace = true
4242
async-trait.workspace = true
4343
backtrace = "0.3"

crates/project/src/project_tests.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3598,7 +3598,7 @@ async fn test_search(cx: &mut gpui::TestAppContext) {
35983598
assert_eq!(
35993599
search(
36003600
&project,
3601-
SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()),
3601+
SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()).unwrap(),
36023602
cx
36033603
)
36043604
.await
@@ -3623,7 +3623,7 @@ async fn test_search(cx: &mut gpui::TestAppContext) {
36233623
assert_eq!(
36243624
search(
36253625
&project,
3626-
SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()),
3626+
SearchQuery::text("TWO", false, true, Vec::new(), Vec::new()).unwrap(),
36273627
cx
36283628
)
36293629
.await
@@ -3664,7 +3664,8 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {
36643664
true,
36653665
vec![PathMatcher::new("*.odd").unwrap()],
36663666
Vec::new()
3667-
),
3667+
)
3668+
.unwrap(),
36683669
cx
36693670
)
36703671
.await
@@ -3682,7 +3683,8 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {
36823683
true,
36833684
vec![PathMatcher::new("*.rs").unwrap()],
36843685
Vec::new()
3685-
),
3686+
)
3687+
.unwrap(),
36863688
cx
36873689
)
36883690
.await
@@ -3706,7 +3708,7 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {
37063708
PathMatcher::new("*.odd").unwrap(),
37073709
],
37083710
Vec::new()
3709-
),
3711+
).unwrap(),
37103712
cx
37113713
)
37123714
.await
@@ -3731,7 +3733,7 @@ async fn test_search_with_inclusions(cx: &mut gpui::TestAppContext) {
37313733
PathMatcher::new("*.odd").unwrap(),
37323734
],
37333735
Vec::new()
3734-
),
3736+
).unwrap(),
37353737
cx
37363738
)
37373739
.await
@@ -3774,7 +3776,8 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {
37743776
true,
37753777
Vec::new(),
37763778
vec![PathMatcher::new("*.odd").unwrap()],
3777-
),
3779+
)
3780+
.unwrap(),
37783781
cx
37793782
)
37803783
.await
@@ -3797,7 +3800,8 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {
37973800
true,
37983801
Vec::new(),
37993802
vec![PathMatcher::new("*.rs").unwrap()],
3800-
),
3803+
)
3804+
.unwrap(),
38013805
cx
38023806
)
38033807
.await
@@ -3821,7 +3825,7 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {
38213825
PathMatcher::new("*.ts").unwrap(),
38223826
PathMatcher::new("*.odd").unwrap(),
38233827
],
3824-
),
3828+
).unwrap(),
38253829
cx
38263830
)
38273831
.await
@@ -3846,7 +3850,7 @@ async fn test_search_with_exclusions(cx: &mut gpui::TestAppContext) {
38463850
PathMatcher::new("*.ts").unwrap(),
38473851
PathMatcher::new("*.odd").unwrap(),
38483852
],
3849-
),
3853+
).unwrap(),
38503854
cx
38513855
)
38523856
.await
@@ -3883,7 +3887,8 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContex
38833887
true,
38843888
vec![PathMatcher::new("*.odd").unwrap()],
38853889
vec![PathMatcher::new("*.odd").unwrap()],
3886-
),
3890+
)
3891+
.unwrap(),
38873892
cx
38883893
)
38893894
.await
@@ -3901,7 +3906,7 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContex
39013906
true,
39023907
vec![PathMatcher::new("*.ts").unwrap()],
39033908
vec![PathMatcher::new("*.ts").unwrap()],
3904-
),
3909+
).unwrap(),
39053910
cx
39063911
)
39073912
.await
@@ -3925,7 +3930,8 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContex
39253930
PathMatcher::new("*.ts").unwrap(),
39263931
PathMatcher::new("*.odd").unwrap()
39273932
],
3928-
),
3933+
)
3934+
.unwrap(),
39293935
cx
39303936
)
39313937
.await
@@ -3949,7 +3955,8 @@ async fn test_search_with_exclusions_and_inclusions(cx: &mut gpui::TestAppContex
39493955
PathMatcher::new("*.rs").unwrap(),
39503956
PathMatcher::new("*.odd").unwrap()
39513957
],
3952-
),
3958+
)
3959+
.unwrap(),
39533960
cx
39543961
)
39553962
.await

0 commit comments

Comments
 (0)