outline_panel: Rename outline_panel::Open to outline_panel::OpenSelectedEntry (#28890)

Closes #27171

The `outline_panel::Open` action seems to open the outline panel, but
instead, it moves the editor's cursor to the position of the selected
entry in the outline panel. This PR renames it to
`outline_panel::OpenSelectedEntry` for better clarity.

Meanwhile, there is an existing action, `outline_panel::ToggleFocus`,
that should be used for opening the outline panel.

Todo:
- [x] Added migration

Release Notes:

- Renamed `outline_panel::Open` to `outline_panel::OpenSelectedEntry`
for better clarity.
This commit is contained in:
Smit Barmase 2025-04-17 01:44:00 +05:30 committed by GitHub
parent 56856fb992
commit 94cf1b0353
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 55 additions and 9 deletions

View file

@ -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;
}

View file

@ -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")])
});

View file

@ -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
);
// settings
define_query!(