diff --git a/crates/migrator/src/migrator.rs b/crates/migrator/src/migrator.rs index 4d0007802fffea..c0910685187f80 100644 --- a/crates/migrator/src/migrator.rs +++ b/crates/migrator/src/migrator.rs @@ -92,10 +92,6 @@ const KEYMAP_MIGRATION_TRANSFORMATION_PATTERNS: MigrationPatterns = &[ ), (ACTION_STRING_PATTERN, rename_string_action), (CONTEXT_PREDICATE_PATTERN, rename_context_key), - ( - ACTION_STRING_OF_ARRAY_PATTERN, - replace_first_string_of_array, - ), ]; static KEYMAP_MIGRATION_TRANSFORMATION_QUERY: LazyLock = LazyLock::new(|| { @@ -269,51 +265,6 @@ static TRANSFORM_ARRAY: LazyLock> = LazyLock::new(|| ]) }); -const ACTION_STRING_OF_ARRAY_PATTERN: &str = r#"(document - (array - (object - (pair - key: (string (string_content) @name) - value: ( - (object - (pair - key: (string) - value: ((array - . (string (string_content) @action_name) - ) - ) - ) - ) - ) - ) - ) - ) - (#eq? @name "bindings") -)"#; - -// ["editor::GoToPrevHunk", { "center_cursor": true }] -> ["editor::GoToPreviousHunk", { "center_cursor": true }] -fn replace_first_string_of_array( - contents: &str, - mat: &QueryMatch, - query: &Query, -) -> Option<(Range, String)> { - let action_name_ix = query.capture_index_for_name("action_name")?; - let action_name = contents.get( - mat.nodes_for_capture_index(action_name_ix) - .next()? - .byte_range(), - )?; - let replacement = STRING_OF_ARRAY_REPLACE.get(action_name)?; - let range_to_replace = mat - .nodes_for_capture_index(action_name_ix) - .next()? - .byte_range(); - Some((range_to_replace, replacement.to_string())) -} - -static STRING_OF_ARRAY_REPLACE: LazyLock> = - LazyLock::new(|| HashMap::from_iter([("editor::GoToPrevHunk", "editor::GoToPreviousHunk")])); - const ACTION_ARGUMENT_OBJECT_PATTERN: &str = r#"(document (array (object @@ -485,6 +436,7 @@ static STRING_REPLACE: LazyLock> = LazyLock::new(|| { ("pane::ActivatePrevItem", "pane::ActivatePreviousItem"), ("vim::MoveToPrev", "vim::MoveToPrevious"), ("vim::MoveToPrevMatch", "vim::MoveToPreviousMatch"), + ("editor::GoToPrevHunk", "editor::GoToPreviousHunk"), ]) }); @@ -926,36 +878,6 @@ mod tests { ) } - #[test] - fn test_string_of_array_replace() { - assert_migrate_keymap( - r#" - [ - { - "bindings": { - "ctrl-p": ["editor::GoToPrevHunk", { "center_cursor": true }], - "ctrl-q": ["editor::GoToPrevHunk"], - "ctrl-q": "editor::GoToPrevHunk", // should remain same - } - } - ] - "#, - Some( - r#" - [ - { - "bindings": { - "ctrl-p": ["editor::GoToPreviousHunk", { "center_cursor": true }], - "ctrl-q": ["editor::GoToPreviousHunk"], - "ctrl-q": "editor::GoToPrevHunk", // should remain same - } - } - ] - "#, - ), - ) - } - #[test] fn test_action_argument_snake_case() { // First performs transformations, then replacements