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
This commit is contained in:
Piotr Osiewicz
2023-09-18 17:01:08 +02:00
committed by GitHub
parent 5c22e40e99
commit 616d328f3c
11 changed files with 99 additions and 67 deletions
+14 -8
View File
@@ -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>) {
+24 -12
View File
@@ -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ˇ»");
}
}