diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index d5bc26b9417daa..74fc26d540d062 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -544,6 +544,7 @@ "m": "vim::PushHelixMatch", "]": ["vim::PushHelixNext", { "around": true }], "[": ["vim::PushHelixPrevious", { "around": true }], + "ctrl-s": "editor::SaveLocation", "g q": "vim::PushRewrap", "g w": "vim::PushRewrap", // not a helix default & clashes with helix `goto_word` }, diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs index 6a05f94cf628cd..8f14e51fb5a2f7 100644 --- a/crates/editor/src/actions.rs +++ b/crates/editor/src/actions.rs @@ -907,6 +907,8 @@ actions!( WrapSelectionsInTag, /// Aligns selections from different rows into the same column AlignSelections, + /// Saves the current location to navigation history. + SaveLocation, ] ); diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index b01d1592abb525..02e1125ac79826 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -15984,6 +15984,15 @@ impl Editor { self.nav_history.as_ref() } + pub fn save_location( + &mut self, + _: &SaveLocation, + _window: &mut Window, + cx: &mut Context, + ) { + self.create_nav_history_entry(cx); + } + pub fn create_nav_history_entry(&mut self, cx: &mut Context) { self.push_to_nav_history( self.selections.newest_anchor().head(), diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index 0646bf7a0683ad..155540b1e28204 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -490,6 +490,7 @@ impl EditorElement { register_action(editor, window, Editor::unfold_all); register_action(editor, window, Editor::fold_selected_ranges); register_action(editor, window, Editor::set_mark); + register_action(editor, window, Editor::save_location); register_action(editor, window, Editor::swap_selection_ends); register_action(editor, window, Editor::show_completions); register_action(editor, window, Editor::show_word_completions);