From 6bf5e92a25e6bb87dfdecc861b5a94c4a6a632c9 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 17 Nov 2025 11:01:34 -0700 Subject: [PATCH] Revert "Keep selection in `SwitchToHelixNormalMode` (#41583)" (#42892) Closes #ISSUE Release Notes: - Fixes vim "go to definition" making a selection --- assets/keymaps/vim.json | 6 --- crates/agent_ui/src/text_thread_editor.rs | 3 +- crates/debugger_tools/src/dap_log.rs | 6 +-- crates/editor/src/editor.rs | 48 ++++++----------- crates/editor/src/items.rs | 3 +- crates/language_tools/src/lsp_log_view.rs | 6 +-- crates/search/src/buffer_search.rs | 21 +++----- crates/search/src/project_search.rs | 9 ++-- crates/terminal_view/src/terminal_view.rs | 1 - crates/vim/src/helix.rs | 64 ++--------------------- crates/vim/src/motion.rs | 45 +++++++--------- crates/vim/src/normal/search.rs | 19 +++---- crates/vim/src/state.rs | 8 +-- crates/vim/src/test.rs | 20 +++++++ crates/vim/src/test/vim_test_context.rs | 1 + crates/vim/src/vim.rs | 4 +- crates/vim/src/visual.rs | 8 ++- crates/workspace/src/searchable.rs | 5 +- 18 files changed, 94 insertions(+), 183 deletions(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index c7b83daab67689d10a6b7c1e28312ceff4551e08..a3530140b39df88a0929df0a21cfb9379a9fc8bd 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -421,12 +421,6 @@ "ctrl-[": "editor::Cancel" } }, - { - "context": "vim_mode == helix_select && !menu", - "bindings": { - "escape": "vim::SwitchToHelixNormalMode" - } - }, { "context": "(vim_mode == helix_normal || vim_mode == helix_select) && !menu", "bindings": { diff --git a/crates/agent_ui/src/text_thread_editor.rs b/crates/agent_ui/src/text_thread_editor.rs index a46bf530217050a1f01ca777ee5e2af108989fbf..84f04f8821b2dd540e54f41f567a0b7735116875 100644 --- a/crates/agent_ui/src/text_thread_editor.rs +++ b/crates/agent_ui/src/text_thread_editor.rs @@ -2626,12 +2626,11 @@ impl SearchableItem for TextThreadEditor { &mut self, index: usize, matches: &[Self::Match], - collapse: bool, window: &mut Window, cx: &mut Context, ) { self.editor.update(cx, |editor, cx| { - editor.activate_match(index, matches, collapse, window, cx); + editor.activate_match(index, matches, window, cx); }); } diff --git a/crates/debugger_tools/src/dap_log.rs b/crates/debugger_tools/src/dap_log.rs index 738c60870f2200e11e710f9c94d02682b94677f7..4c994ad7eb749dcb5828daa83bad34a579f9f14c 100644 --- a/crates/debugger_tools/src/dap_log.rs +++ b/crates/debugger_tools/src/dap_log.rs @@ -1029,13 +1029,11 @@ impl SearchableItem for DapLogView { &mut self, index: usize, matches: &[Self::Match], - collapse: bool, window: &mut Window, cx: &mut Context, ) { - self.editor.update(cx, |e, cx| { - e.activate_match(index, matches, collapse, window, cx) - }) + self.editor + .update(cx, |e, cx| e.activate_match(index, matches, window, cx)) } fn select_matches( diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 8cb3d1abf7d026e7201c60834f355d0f5e56671d..339b0354c3fc0859cfe791fd69336535645c14c8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1099,6 +1099,7 @@ pub struct Editor { searchable: bool, cursor_shape: CursorShape, current_line_highlight: Option, + collapse_matches: bool, autoindent_mode: Option, workspace: Option<(WeakEntity, Option)>, input_enabled: bool, @@ -2211,7 +2212,7 @@ impl Editor { .unwrap_or_default(), current_line_highlight: None, autoindent_mode: Some(AutoindentMode::EachLine), - + collapse_matches: false, workspace: None, input_enabled: !is_minimap, use_modal_editing: full_mode, @@ -2384,7 +2385,10 @@ impl Editor { } } EditorEvent::Edited { .. } => { - if vim_flavor(cx).is_none() { + let vim_mode = vim_mode_setting::VimModeSetting::try_get(cx) + .map(|vim_mode| vim_mode.0) + .unwrap_or(false); + if !vim_mode { let display_map = editor.display_snapshot(cx); let selections = editor.selections.all_adjusted_display(&display_map); let pop_state = editor @@ -3013,12 +3017,12 @@ impl Editor { self.current_line_highlight = current_line_highlight; } - pub fn range_for_match( - &self, - range: &Range, - collapse: bool, - ) -> Range { - if collapse { + pub fn set_collapse_matches(&mut self, collapse_matches: bool) { + self.collapse_matches = collapse_matches; + } + + pub fn range_for_match(&self, range: &Range) -> Range { + if self.collapse_matches { return range.start..range.start; } range.clone() @@ -16921,7 +16925,7 @@ impl Editor { editor.update_in(cx, |editor, window, cx| { let range = target_range.to_point(target_buffer.read(cx)); - let range = editor.range_for_match(&range, false); + let range = editor.range_for_match(&range); let range = collapse_multiline_range(range); if !split @@ -21761,7 +21765,9 @@ impl Editor { .and_then(|e| e.to_str()) .map(|a| a.to_string())); - let vim_mode = vim_flavor(cx).is_some(); + let vim_mode = vim_mode_setting::VimModeSetting::try_get(cx) + .map(|vim_mode| vim_mode.0) + .unwrap_or(false); let edit_predictions_provider = all_language_settings(file, cx).edit_predictions.provider; let copilot_enabled = edit_predictions_provider @@ -22396,28 +22402,6 @@ fn edit_for_markdown_paste<'a>( (range, new_text) } -#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] -pub enum VimFlavor { - Vim, - Helix, -} - -pub fn vim_flavor(cx: &App) -> Option { - if vim_mode_setting::HelixModeSetting::try_get(cx) - .map(|helix_mode| helix_mode.0) - .unwrap_or(false) - { - Some(VimFlavor::Helix) - } else if vim_mode_setting::VimModeSetting::try_get(cx) - .map(|vim_mode| vim_mode.0) - .unwrap_or(false) - { - Some(VimFlavor::Vim) - } else { - None // neither vim nor helix mode - } -} - fn process_completion_for_edit( completion: &Completion, intent: CompletionIntent, diff --git a/crates/editor/src/items.rs b/crates/editor/src/items.rs index 12590e4b3f95648dd653d408252ced460e2e834e..a860e137a856a2e7982f1177c205391b80625944 100644 --- a/crates/editor/src/items.rs +++ b/crates/editor/src/items.rs @@ -1586,12 +1586,11 @@ impl SearchableItem for Editor { &mut self, index: usize, matches: &[Range], - collapse: bool, window: &mut Window, cx: &mut Context, ) { self.unfold_ranges(&[matches[index].clone()], false, true, cx); - let range = self.range_for_match(&matches[index], collapse); + let range = self.range_for_match(&matches[index]); let autoscroll = if EditorSettings::get_global(cx).search.center_on_match { Autoscroll::center() } else { diff --git a/crates/language_tools/src/lsp_log_view.rs b/crates/language_tools/src/lsp_log_view.rs index ef9cc1ef3af88310d5870aa4d2da3d1a077139f1..d480eadc73b9546e5a59b204b036a3ff88a018c7 100644 --- a/crates/language_tools/src/lsp_log_view.rs +++ b/crates/language_tools/src/lsp_log_view.rs @@ -812,13 +812,11 @@ impl SearchableItem for LspLogView { &mut self, index: usize, matches: &[Self::Match], - collapse: bool, window: &mut Window, cx: &mut Context, ) { - self.editor.update(cx, |e, cx| { - e.activate_match(index, matches, collapse, window, cx) - }) + self.editor + .update(cx, |e, cx| e.activate_match(index, matches, window, cx)) } fn select_matches( diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 764d0a81f7ac8c7fd03fe63c478aea14b3e2e31b..a601f5a683f2c464e792c351c566358212bdf312 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -10,9 +10,8 @@ use any_vec::AnyVec; use anyhow::Context as _; use collections::HashMap; use editor::{ - DisplayPoint, Editor, EditorSettings, VimFlavor, + DisplayPoint, Editor, EditorSettings, actions::{Backtab, Tab}, - vim_flavor, }; use futures::channel::oneshot; use gpui::{ @@ -828,8 +827,7 @@ impl BufferSearchBar { .searchable_items_with_matches .get(&active_searchable_item.downgrade()) { - let collapse = editor::vim_flavor(cx) == Some(VimFlavor::Vim); - active_searchable_item.activate_match(match_ix, matches, collapse, window, cx) + active_searchable_item.activate_match(match_ix, matches, window, cx) } } @@ -976,8 +974,7 @@ impl BufferSearchBar { window: &mut Window, cx: &mut Context, ) { - let collapse = vim_flavor(cx) == Some(VimFlavor::Vim); - self.select_match(Direction::Next, 1, collapse, window, cx); + self.select_match(Direction::Next, 1, window, cx); } fn select_prev_match( @@ -986,8 +983,7 @@ impl BufferSearchBar { window: &mut Window, cx: &mut Context, ) { - let collapse = vim_flavor(cx) == Some(VimFlavor::Vim); - self.select_match(Direction::Prev, 1, collapse, window, cx); + self.select_match(Direction::Prev, 1, window, cx); } pub fn select_all_matches( @@ -1012,7 +1008,6 @@ impl BufferSearchBar { &mut self, direction: Direction, count: usize, - collapse: bool, window: &mut Window, cx: &mut Context, ) { @@ -1035,7 +1030,7 @@ impl BufferSearchBar { .match_index_for_direction(matches, index, direction, count, window, cx); searchable_item.update_matches(matches, window, cx); - searchable_item.activate_match(new_match_index, matches, collapse, window, cx); + searchable_item.activate_match(new_match_index, matches, window, cx); } } @@ -1049,8 +1044,7 @@ impl BufferSearchBar { return; } searchable_item.update_matches(matches, window, cx); - let collapse = vim_flavor(cx) == Some(VimFlavor::Vim); - searchable_item.activate_match(0, matches, collapse, window, cx); + searchable_item.activate_match(0, matches, window, cx); } } @@ -1065,8 +1059,7 @@ impl BufferSearchBar { } let new_match_index = matches.len() - 1; searchable_item.update_matches(matches, window, cx); - let collapse = vim_flavor(cx) == Some(VimFlavor::Vim); - searchable_item.activate_match(new_match_index, matches, collapse, window, cx); + searchable_item.activate_match(new_match_index, matches, window, cx); } } diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index 001b7e3fbb09b8d4888f2e4744ca8ecb1096d7a6..1768b0f18541fd289126bad77ae46eded1aad326 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -9,12 +9,11 @@ use anyhow::Context as _; use collections::HashMap; use editor::{ Anchor, Editor, EditorEvent, EditorSettings, MAX_TAB_TITLE_LEN, MultiBuffer, PathKey, - SelectionEffects, VimFlavor, + SelectionEffects, actions::{Backtab, SelectAll, Tab}, items::active_match_index, multibuffer_context_lines, scroll::Autoscroll, - vim_flavor, }; use futures::{StreamExt, stream::FuturesOrdered}; use gpui::{ @@ -1431,8 +1430,7 @@ impl ProjectSearchView { let range_to_select = match_ranges[new_index].clone(); self.results_editor.update(cx, |editor, cx| { - let collapse = vim_flavor(cx) == Some(VimFlavor::Vim); - let range_to_select = editor.range_for_match(&range_to_select, collapse); + let range_to_select = editor.range_for_match(&range_to_select); let autoscroll = if EditorSettings::get_global(cx).search.center_on_match { Autoscroll::center() } else { @@ -1509,10 +1507,9 @@ impl ProjectSearchView { let is_new_search = self.search_id != prev_search_id; self.results_editor.update(cx, |editor, cx| { if is_new_search { - let collapse = vim_flavor(cx) == Some(VimFlavor::Vim); let range_to_select = match_ranges .first() - .map(|range| editor.range_for_match(range, collapse)); + .map(|range| editor.range_for_match(range)); editor.change_selections(Default::default(), window, cx, |s| { s.select_ranges(range_to_select) }); diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 43714a5cfeee690644e9b772d89c12bcbd909964..b9dabee7e82064ebe055893306241f995654b82b 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -1452,7 +1452,6 @@ impl SearchableItem for TerminalView { &mut self, index: usize, _: &[Self::Match], - _collapse: bool, _window: &mut Window, cx: &mut Context, ) { diff --git a/crates/vim/src/helix.rs b/crates/vim/src/helix.rs index ee7c0a14fb721116c3fc1f2c3d1bf7b716b43f18..6788a186fb45222f7b09fe756862e6cb337c6d90 100644 --- a/crates/vim/src/helix.rs +++ b/crates/vim/src/helix.rs @@ -450,7 +450,7 @@ impl Vim { prior_selections, prior_operator: self.operator_stack.last().cloned(), prior_mode: self.mode, - is_helix_regex_search: true, + helix_select: true, } }); } @@ -1278,24 +1278,6 @@ mod test { cx.assert_state("«one ˇ»two", Mode::HelixSelect); } - #[gpui::test] - async fn test_exit_visual_mode(cx: &mut gpui::TestAppContext) { - let mut cx = VimTestContext::new(cx, true).await; - - cx.set_state("ˇone two", Mode::Normal); - cx.simulate_keystrokes("v w"); - cx.assert_state("«one tˇ»wo", Mode::Visual); - cx.simulate_keystrokes("escape"); - cx.assert_state("one ˇtwo", Mode::Normal); - - cx.enable_helix(); - cx.set_state("ˇone two", Mode::HelixNormal); - cx.simulate_keystrokes("v w"); - cx.assert_state("«one ˇ»two", Mode::HelixSelect); - cx.simulate_keystrokes("escape"); - cx.assert_state("«one ˇ»two", Mode::HelixNormal); - } - #[gpui::test] async fn test_helix_select_regex(cx: &mut gpui::TestAppContext) { let mut cx = VimTestContext::new(cx, true).await; @@ -1315,47 +1297,9 @@ mod test { cx.simulate_keystrokes("enter"); cx.assert_state("«oneˇ» two «oneˇ»", Mode::HelixNormal); - // TODO: change "search_in_selection" to not perform any search when in helix select mode with no selection - // cx.set_state("ˇstuff one two one", Mode::HelixNormal); - // cx.simulate_keystrokes("s o n e enter"); - // cx.assert_state("ˇstuff one two one", Mode::HelixNormal); - } - - #[gpui::test] - async fn test_helix_select_next_match(cx: &mut gpui::TestAppContext) { - let mut cx = VimTestContext::new(cx, true).await; - - cx.set_state("ˇhello two one two one two one", Mode::Visual); - cx.simulate_keystrokes("/ o n e"); - cx.simulate_keystrokes("enter"); - cx.simulate_keystrokes("n n"); - cx.assert_state("«hello two one two one two oˇ»ne", Mode::Visual); - - cx.set_state("ˇhello two one two one two one", Mode::Normal); - cx.simulate_keystrokes("/ o n e"); - cx.simulate_keystrokes("enter"); - cx.simulate_keystrokes("n n"); - cx.assert_state("hello two one two one two ˇone", Mode::Normal); - - cx.set_state("ˇhello two one two one two one", Mode::Normal); - cx.simulate_keystrokes("/ o n e"); - cx.simulate_keystrokes("enter"); - cx.simulate_keystrokes("n g n g n"); - cx.assert_state("hello two one two «one two oneˇ»", Mode::Visual); - - cx.enable_helix(); - - cx.set_state("ˇhello two one two one two one", Mode::HelixNormal); - cx.simulate_keystrokes("/ o n e"); - cx.simulate_keystrokes("enter"); - cx.simulate_keystrokes("n n"); - cx.assert_state("hello two one two one two «oneˇ»", Mode::HelixNormal); - - cx.set_state("ˇhello two one two one two one", Mode::HelixSelect); - cx.simulate_keystrokes("/ o n e"); - cx.simulate_keystrokes("enter"); - cx.simulate_keystrokes("n n"); - cx.assert_state("ˇhello two «oneˇ» two «oneˇ» two «oneˇ»", Mode::HelixSelect); + cx.set_state("ˇone two one", Mode::HelixNormal); + cx.simulate_keystrokes("s o n e enter"); + cx.assert_state("ˇone two one", Mode::HelixNormal); } #[gpui::test] diff --git a/crates/vim/src/motion.rs b/crates/vim/src/motion.rs index 0264ea9176fb2264bc693888fb861ff33d5be706..c0be92b38e46e7d8c32c9da4a6980195ef71a91e 100644 --- a/crates/vim/src/motion.rs +++ b/crates/vim/src/motion.rs @@ -672,40 +672,31 @@ pub fn register(editor: &mut Editor, cx: &mut Context) { impl Vim { pub(crate) fn search_motion(&mut self, m: Motion, window: &mut Window, cx: &mut Context) { - let Motion::ZedSearchResult { - prior_selections, - new_selections, + if let Motion::ZedSearchResult { + prior_selections, .. } = &m - else { - return; - }; - - match self.mode { - Mode::Visual | Mode::VisualLine | Mode::VisualBlock => { - if !prior_selections.is_empty() { - self.update_editor(cx, |_, editor, cx| { - editor.change_selections(Default::default(), window, cx, |s| { - s.select_ranges(prior_selections.iter().cloned()); + { + match self.mode { + Mode::Visual | Mode::VisualLine | Mode::VisualBlock => { + if !prior_selections.is_empty() { + self.update_editor(cx, |_, editor, cx| { + editor.change_selections(Default::default(), window, cx, |s| { + s.select_ranges(prior_selections.iter().cloned()) + }) }); - }); + } } - self.motion(m, window, cx); - } - Mode::Normal | Mode::Replace | Mode::Insert => { - if self.active_operator().is_some() { - self.motion(m, window, cx); + Mode::Normal | Mode::Replace | Mode::Insert => { + if self.active_operator().is_none() { + return; + } } - } - Mode::HelixNormal => {} - Mode::HelixSelect => { - self.update_editor(cx, |_, editor, cx| { - editor.change_selections(Default::default(), window, cx, |s| { - s.select_ranges(prior_selections.iter().chain(new_selections).cloned()); - }); - }); + Mode::HelixNormal | Mode::HelixSelect => {} } } + + self.motion(m, window, cx) } pub(crate) fn motion(&mut self, motion: Motion, window: &mut Window, cx: &mut Context) { diff --git a/crates/vim/src/normal/search.rs b/crates/vim/src/normal/search.rs index 2e80a08eb824b93783bf1249970e5e7ad7378ff2..6c4294a474dad13c9d00e58ab117a4a6a74c28d3 100644 --- a/crates/vim/src/normal/search.rs +++ b/crates/vim/src/normal/search.rs @@ -1,6 +1,5 @@ -use editor::{Editor, EditorSettings, VimFlavor}; +use editor::{Editor, EditorSettings}; use gpui::{Action, Context, Window, actions}; - use language::Point; use schemars::JsonSchema; use search::{BufferSearchBar, SearchOptions, buffer_search}; @@ -196,7 +195,7 @@ impl Vim { prior_selections, prior_operator: self.operator_stack.last().cloned(), prior_mode, - is_helix_regex_search: false, + helix_select: false, } }); } @@ -220,7 +219,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::()?; - if self.search.is_helix_regex_search { + if self.search.helix_select { search_bar.update(cx, |search_bar, cx| { search_bar.select_all_matches(&Default::default(), window, cx) }); @@ -241,8 +240,7 @@ impl Vim { count = count.saturating_sub(1) } self.search.count = 1; - let collapse = !self.mode.is_helix(); - search_bar.select_match(direction, count, collapse, window, cx); + search_bar.select_match(direction, count, window, cx); search_bar.focus_editor(&Default::default(), window, cx); let prior_selections: Vec<_> = self.search.prior_selections.drain(..).collect(); @@ -309,8 +307,7 @@ impl Vim { if !search_bar.has_active_match() || !search_bar.show(window, cx) { return false; } - let collapse = !self.mode.is_helix(); - search_bar.select_match(direction, count, collapse, window, cx); + search_bar.select_match(direction, count, window, cx); true }) }); @@ -319,7 +316,6 @@ impl Vim { } let new_selections = self.editor_selections(window, cx); - self.search_motion( Motion::ZedSearchResult { prior_selections, @@ -385,8 +381,7 @@ impl Vim { cx.spawn_in(window, async move |_, cx| { search.await?; search_bar.update_in(cx, |search_bar, window, cx| { - let collapse = editor::vim_flavor(cx) == Some(VimFlavor::Vim); - search_bar.select_match(direction, count, collapse, window, cx); + search_bar.select_match(direction, count, window, cx); vim.update(cx, |vim, cx| { let new_selections = vim.editor_selections(window, cx); @@ -449,7 +444,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, true, window, cx) + search_bar.select_match(direction, 1, window, cx) })?; anyhow::Ok(()) }) diff --git a/crates/vim/src/state.rs b/crates/vim/src/state.rs index 8a7b85349273176f67e8eed8b6939ef047f83b4c..d1c52e8f53a2214c3e46473c59b15ea1f6f4f407 100644 --- a/crates/vim/src/state.rs +++ b/crates/vim/src/state.rs @@ -67,16 +67,12 @@ impl Display for Mode { } impl Mode { - pub fn is_visual(self) -> bool { + pub fn is_visual(&self) -> bool { match self { Self::Visual | Self::VisualLine | Self::VisualBlock | Self::HelixSelect => true, Self::Normal | Self::Insert | Self::Replace | Self::HelixNormal => false, } } - - pub fn is_helix(self) -> bool { - matches!(self, Mode::HelixNormal | Mode::HelixSelect) - } } #[derive(Clone, Debug, PartialEq)] @@ -991,7 +987,7 @@ pub struct SearchState { pub prior_selections: Vec>, pub prior_operator: Option, pub prior_mode: Mode, - pub is_helix_regex_search: bool, + pub helix_select: bool, } impl Operator { diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index d6aa116e8ddb12c0f3aff15fbe971b701fe90ab7..3cd0646ff4fc0a6966f12db75b64999e3655ab98 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -1139,6 +1139,26 @@ async fn test_rename(cx: &mut gpui::TestAppContext) { cx.assert_state("const afterˇ = 2; console.log(after)", Mode::Normal) } +#[gpui::test] +async fn test_go_to_definition(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new_typescript(cx).await; + + cx.set_state("const before = 2; console.log(beforˇe)", Mode::Normal); + let def_range = cx.lsp_range("const «beforeˇ» = 2; console.log(before)"); + let mut go_to_request = + cx.set_request_handler::(move |url, _, _| async move { + Ok(Some(lsp::GotoDefinitionResponse::Scalar( + lsp::Location::new(url.clone(), def_range), + ))) + }); + + cx.simulate_keystrokes("g d"); + go_to_request.next().await.unwrap(); + cx.run_until_parked(); + + cx.assert_state("const ˇbefore = 2; console.log(before)", Mode::Normal); +} + #[perf] #[gpui::test] async fn test_remap(cx: &mut gpui::TestAppContext) { diff --git a/crates/vim/src/test/vim_test_context.rs b/crates/vim/src/test/vim_test_context.rs index 4d6859f1e56976fbb0d84d475e614325e0e52795..1e92715d2b3c874f110c0fa76b2a7d747fbf3b51 100644 --- a/crates/vim/src/test/vim_test_context.rs +++ b/crates/vim/src/test/vim_test_context.rs @@ -59,6 +59,7 @@ impl VimTestContext { prepare_provider: Some(true), work_done_progress_options: Default::default(), })), + definition_provider: Some(lsp::OneOf::Left(true)), ..Default::default() }, cx, diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 6ffdbcce910c10229dc7c2e6df95055c5c812f28..a0efd1ee29a3c72793c331cf4ccbeb38444bd55b 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -668,7 +668,7 @@ impl Vim { editor, cx, |vim, _: &SwitchToHelixNormalMode, window, cx| { - vim.switch_mode(Mode::HelixNormal, true, window, cx) + vim.switch_mode(Mode::HelixNormal, false, window, cx) }, ); Vim::action(editor, cx, |_, _: &PushForcedMotion, _, cx| { @@ -954,6 +954,7 @@ impl Vim { fn deactivate(editor: &mut Editor, cx: &mut Context) { editor.set_cursor_shape(CursorShape::Bar, cx); editor.set_clip_at_line_ends(false, cx); + editor.set_collapse_matches(false); editor.set_input_enabled(true); editor.set_autoindent(true); editor.selections.set_line_mode(false); @@ -1929,6 +1930,7 @@ impl Vim { self.update_editor(cx, |vim, editor, cx| { editor.set_cursor_shape(vim.cursor_shape(cx), cx); editor.set_clip_at_line_ends(vim.clip_at_line_ends(), cx); + editor.set_collapse_matches(true); editor.set_input_enabled(vim.editor_input_enabled()); editor.set_autoindent(vim.should_autoindent()); editor diff --git a/crates/vim/src/visual.rs b/crates/vim/src/visual.rs index 4172de80afdc1beacbf3ea342846de03953e1fc6..0abba86e993a76b6c2a1c18f02d68d72d092e78c 100644 --- a/crates/vim/src/visual.rs +++ b/crates/vim/src/visual.rs @@ -847,6 +847,9 @@ impl Vim { let mut start_selection = 0usize; let mut end_selection = 0usize; + self.update_editor(cx, |_, editor, _| { + editor.set_collapse_matches(false); + }); if vim_is_normal { pane.update(cx, |pane, cx| { if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::() @@ -857,7 +860,7 @@ impl Vim { } // without update_match_index there is a bug when the cursor is before the first match search_bar.update_match_index(window, cx); - search_bar.select_match(direction.opposite(), 1, false, window, cx); + search_bar.select_match(direction.opposite(), 1, window, cx); }); } }); @@ -875,7 +878,7 @@ impl Vim { if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::() { search_bar.update(cx, |search_bar, cx| { search_bar.update_match_index(window, cx); - search_bar.select_match(direction, count, false, window, cx); + search_bar.select_match(direction, count, window, cx); match_exists = search_bar.match_exists(window, cx); }); } @@ -902,6 +905,7 @@ impl Vim { editor.change_selections(Default::default(), window, cx, |s| { s.select_ranges([start_selection..end_selection]); }); + editor.set_collapse_matches(true); }); match self.maybe_pop_operator() { diff --git a/crates/workspace/src/searchable.rs b/crates/workspace/src/searchable.rs index 9907df3be3eb8594f6cc8f63f05e2e93befd416c..0becddc1641e8abb388837187f47f0a80327a6b5 100644 --- a/crates/workspace/src/searchable.rs +++ b/crates/workspace/src/searchable.rs @@ -104,7 +104,6 @@ pub trait SearchableItem: Item + EventEmitter { &mut self, index: usize, matches: &[Self::Match], - collapse: bool, window: &mut Window, cx: &mut Context, ); @@ -186,7 +185,6 @@ pub trait SearchableItemHandle: ItemHandle { &self, index: usize, matches: &AnyVec, - collapse: bool, window: &mut Window, cx: &mut App, ); @@ -279,13 +277,12 @@ impl SearchableItemHandle for Entity { &self, index: usize, matches: &AnyVec, - collapse: bool, window: &mut Window, cx: &mut App, ) { let matches = matches.downcast_ref().unwrap(); self.update(cx, |this, cx| { - this.activate_match(index, matches.as_slice(), collapse, window, cx) + this.activate_match(index, matches.as_slice(), window, cx) }); }