Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
outline_panel: Rename `outline_panel::Open` to `outline_panel::OpenSelectedEntry` (#28890)
Smit Barmase94cf1b0353ce
diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.jsonindex bcff3116ec3..cc7a55ad0ab 100644--- a/assets/keymaps/default-linux.json+++ b/assets/keymaps/default-linux.json@@ -721,7 +721,7 @@"alt-shift-copy": "workspace::CopyRelativePath","alt-ctrl-shift-c": "workspace::CopyRelativePath","alt-ctrl-r": "outline_panel::RevealInFileManager",- "space": "outline_panel::Open",+ "space": "outline_panel::OpenSelectedEntry","shift-down": "menu::SelectNext","shift-up": "menu::SelectPrevious","alt-enter": "editor::OpenExcerpts",diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.jsonindex e2a6f67e99f..71a144f5b78 100644--- a/assets/keymaps/default-macos.json+++ b/assets/keymaps/default-macos.json@@ -789,7 +789,7 @@"cmd-alt-c": "workspace::CopyPath","alt-cmd-shift-c": "workspace::CopyRelativePath","alt-cmd-r": "outline_panel::RevealInFileManager",- "space": "outline_panel::Open",+ "space": "outline_panel::OpenSelectedEntry","shift-down": "menu::SelectNext","shift-up": "menu::SelectPrevious","alt-enter": "editor::OpenExcerpts",diff --git a/crates/migrator/src/migrations.rs b/crates/migrator/src/migrations.rsindex 394a5fc14f3..7f5d7b84d6d 100644--- a/crates/migrator/src/migrations.rs+++ b/crates/migrator/src/migrations.rs@@ -39,7 +39,9 @@ pub(crate) mod m_2025_03_29 {}pub(crate) mod m_2025_04_15 {+ mod keymap;mod settings;+ pub(crate) use keymap::KEYMAP_PATTERNS;pub(crate) use settings::SETTINGS_PATTERNS;}diff --git a/crates/migrator/src/migrations/m_2025_04_15/keymap.rs b/crates/migrator/src/migrations/m_2025_04_15/keymap.rsnew file mode 100644index 00000000000..d1443a922af--- /dev/null+++ b/crates/migrator/src/migrations/m_2025_04_15/keymap.rs@@ -0,0 +1,31 @@+use collections::HashMap;+use std::{ops::Range, sync::LazyLock};+use tree_sitter::{Query, QueryMatch};++use crate::MigrationPatterns;+use crate::patterns::KEYMAP_ACTION_STRING_PATTERN;++pub const KEYMAP_PATTERNS: MigrationPatterns =+ &[(KEYMAP_ACTION_STRING_PATTERN, replace_string_action)];++fn replace_string_action(+ contents: &str,+ mat: &QueryMatch,+ query: &Query,+) -> Option<(Range<usize>, String)> {+ let action_name_ix = query.capture_index_for_name("action_name")?;+ let action_name_node = mat.nodes_for_capture_index(action_name_ix).next()?;+ let action_name_range = action_name_node.byte_range();+ let action_name = contents.get(action_name_range.clone())?;++ if let Some(new_action_name) = STRING_REPLACE.get(&action_name) {+ return Some((action_name_range, new_action_name.to_string()));+ }++ None+}++/// "ctrl-k ctrl-1": "inline_completion::ToggleMenu" -> "edit_prediction::ToggleMenu"+static STRING_REPLACE: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {+ HashMap::from_iter([("outline_panel::Open", "outline_panel::OpenSelectedEntry")])+});diff --git a/crates/migrator/src/migrator.rs b/crates/migrator/src/migrator.rsindex f5682064922..953de0b37aa 100644--- a/crates/migrator/src/migrator.rs+++ b/crates/migrator/src/migrator.rs@@ -98,6 +98,10 @@ pub fn migrate_keymap(text: &str) -> Result<Option<String>> {migrations::m_2025_03_06::KEYMAP_PATTERNS,&KEYMAP_QUERY_2025_03_06,),+ (+ migrations::m_2025_04_15::KEYMAP_PATTERNS,+ &KEYMAP_QUERY_2025_04_15,+ ),];run_migrations(text, migrations)}@@ -176,6 +180,10 @@ define_query!(KEYMAP_QUERY_2025_03_06,migrations::m_2025_03_06::KEYMAP_PATTERNS);+define_query!(+ KEYMAP_QUERY_2025_04_15,+ migrations::m_2025_04_15::KEYMAP_PATTERNS+);// settingsdefine_query!(diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rsindex d4d20b488ad..648cd5ff3bf 100644--- a/crates/outline_panel/src/outline_panel.rs+++ b/crates/outline_panel/src/outline_panel.rs@@ -70,7 +70,7 @@ actions!(ExpandAllEntries,ExpandSelectedEntry,FoldDirectory,- Open,+ OpenSelectedEntry,RevealInFileManager,SelectParent,ToggleActiveEditorPin,@@ -922,7 +922,12 @@ impl OutlinePanel {self.update_cached_entries(None, window, cx);}- fn open(&mut self, _: &Open, window: &mut Window, cx: &mut Context<Self>) {+ fn open_selected_entry(+ &mut self,+ _: &OpenSelectedEntry,+ window: &mut Window,+ cx: &mut Context<Self>,+ ) {if self.filter_editor.focus_handle(cx).is_focused(window) {cx.propagate()} else if let Some(selected_entry) = self.selected_entry().cloned() {@@ -4906,7 +4911,7 @@ impl Render for OutlinePanel {}})).key_context(self.dispatch_context(window, cx))- .on_action(cx.listener(Self::open))+ .on_action(cx.listener(Self::open_selected_entry)).on_action(cx.listener(Self::cancel)).on_action(cx.listener(Self::select_next)).on_action(cx.listener(Self::select_previous))@@ -5677,7 +5682,7 @@ mod tests {});outline_panel.update_in(cx, |outline_panel, window, cx| {- outline_panel.open(&Open, window, cx);+ outline_panel.open_selected_entry(&OpenSelectedEntry, window, cx);});outline_panel.update(cx, |_outline_panel, cx| {assert_eq!(@@ -5852,7 +5857,7 @@ mod tests {outline_panel.update_in(cx, |outline_panel, window, cx| {outline_panel.select_previous(&SelectPrevious, window, cx);- outline_panel.open(&Open, window, cx);+ outline_panel.open_selected_entry(&OpenSelectedEntry, window, cx);});cx.executor().advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));@@ -5876,7 +5881,7 @@ mod tests {outline_panel.update_in(cx, |outline_panel, window, cx| {outline_panel.select_next(&SelectNext, window, cx);- outline_panel.open(&Open, window, cx);+ outline_panel.open_selected_entry(&OpenSelectedEntry, window, cx);});cx.executor().advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));@@ -5897,7 +5902,7 @@ mod tests {});outline_panel.update_in(cx, |outline_panel, window, cx| {- outline_panel.open(&Open, window, cx);+ outline_panel.open_selected_entry(&OpenSelectedEntry, window, cx);});cx.executor().advance_clock(UPDATE_DEBOUNCE + Duration::from_millis(100));