Keep selection in SwitchToHelixNormalMode (#41583)
Closes #41125 Release Notes: - Fixed `SwitchToHelixNormalMode` to keep selection - Added default keybinds for `SwitchToHelixNormalMode` when in Helix mode
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use editor::{Editor, EditorSettings};
|
||||
use editor::{Editor, EditorSettings, VimFlavor};
|
||||
use gpui::{Action, Context, Window, actions};
|
||||
|
||||
use language::Point;
|
||||
use schemars::JsonSchema;
|
||||
use search::{BufferSearchBar, SearchOptions, buffer_search};
|
||||
@@ -195,7 +196,7 @@ impl Vim {
|
||||
prior_selections,
|
||||
prior_operator: self.operator_stack.last().cloned(),
|
||||
prior_mode,
|
||||
helix_select: false,
|
||||
is_helix_regex_search: false,
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -219,7 +220,7 @@ impl Vim {
|
||||
let new_selections = self.editor_selections(window, cx);
|
||||
let result = pane.update(cx, |pane, cx| {
|
||||
let search_bar = pane.toolbar().read(cx).item_of_type::<BufferSearchBar>()?;
|
||||
if self.search.helix_select {
|
||||
if self.search.is_helix_regex_search {
|
||||
search_bar.update(cx, |search_bar, cx| {
|
||||
search_bar.select_all_matches(&Default::default(), window, cx)
|
||||
});
|
||||
@@ -240,7 +241,8 @@ impl Vim {
|
||||
count = count.saturating_sub(1)
|
||||
}
|
||||
self.search.count = 1;
|
||||
search_bar.select_match(direction, count, window, cx);
|
||||
let collapse = !self.mode.is_helix();
|
||||
search_bar.select_match(direction, count, collapse, window, cx);
|
||||
search_bar.focus_editor(&Default::default(), window, cx);
|
||||
|
||||
let prior_selections: Vec<_> = self.search.prior_selections.drain(..).collect();
|
||||
@@ -307,7 +309,8 @@ impl Vim {
|
||||
if !search_bar.has_active_match() || !search_bar.show(window, cx) {
|
||||
return false;
|
||||
}
|
||||
search_bar.select_match(direction, count, window, cx);
|
||||
let collapse = !self.mode.is_helix();
|
||||
search_bar.select_match(direction, count, collapse, window, cx);
|
||||
true
|
||||
})
|
||||
});
|
||||
@@ -316,6 +319,7 @@ impl Vim {
|
||||
}
|
||||
|
||||
let new_selections = self.editor_selections(window, cx);
|
||||
|
||||
self.search_motion(
|
||||
Motion::ZedSearchResult {
|
||||
prior_selections,
|
||||
@@ -381,7 +385,8 @@ impl Vim {
|
||||
cx.spawn_in(window, async move |_, cx| {
|
||||
search.await?;
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
search_bar.select_match(direction, count, window, cx);
|
||||
let collapse = editor::vim_flavor(cx) == Some(VimFlavor::Vim);
|
||||
search_bar.select_match(direction, count, collapse, window, cx);
|
||||
|
||||
vim.update(cx, |vim, cx| {
|
||||
let new_selections = vim.editor_selections(window, cx);
|
||||
@@ -444,7 +449,7 @@ impl Vim {
|
||||
cx.spawn_in(window, async move |_, cx| {
|
||||
search.await?;
|
||||
search_bar.update_in(cx, |search_bar, window, cx| {
|
||||
search_bar.select_match(direction, 1, window, cx)
|
||||
search_bar.select_match(direction, 1, true, window, cx)
|
||||
})?;
|
||||
anyhow::Ok(())
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user