Skip to content

Commit efe4418

Browse files
committed
on stable, this action only exists as string.
1 parent 64b2ddc commit efe4418

File tree

1 file changed

+1
-79
lines changed

1 file changed

+1
-79
lines changed

crates/migrator/src/migrator.rs

Lines changed: 1 addition & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,6 @@ const KEYMAP_MIGRATION_TRANSFORMATION_PATTERNS: MigrationPatterns = &[
9292
),
9393
(ACTION_STRING_PATTERN, rename_string_action),
9494
(CONTEXT_PREDICATE_PATTERN, rename_context_key),
95-
(
96-
ACTION_STRING_OF_ARRAY_PATTERN,
97-
replace_first_string_of_array,
98-
),
9995
];
10096

10197
static KEYMAP_MIGRATION_TRANSFORMATION_QUERY: LazyLock<Query> = LazyLock::new(|| {
@@ -269,51 +265,6 @@ static TRANSFORM_ARRAY: LazyLock<HashMap<(&str, &str), &str>> = LazyLock::new(||
269265
])
270266
});
271267

272-
const ACTION_STRING_OF_ARRAY_PATTERN: &str = r#"(document
273-
(array
274-
(object
275-
(pair
276-
key: (string (string_content) @name)
277-
value: (
278-
(object
279-
(pair
280-
key: (string)
281-
value: ((array
282-
. (string (string_content) @action_name)
283-
)
284-
)
285-
)
286-
)
287-
)
288-
)
289-
)
290-
)
291-
(#eq? @name "bindings")
292-
)"#;
293-
294-
// ["editor::GoToPrevHunk", { "center_cursor": true }] -> ["editor::GoToPreviousHunk", { "center_cursor": true }]
295-
fn replace_first_string_of_array(
296-
contents: &str,
297-
mat: &QueryMatch,
298-
query: &Query,
299-
) -> Option<(Range<usize>, String)> {
300-
let action_name_ix = query.capture_index_for_name("action_name")?;
301-
let action_name = contents.get(
302-
mat.nodes_for_capture_index(action_name_ix)
303-
.next()?
304-
.byte_range(),
305-
)?;
306-
let replacement = STRING_OF_ARRAY_REPLACE.get(action_name)?;
307-
let range_to_replace = mat
308-
.nodes_for_capture_index(action_name_ix)
309-
.next()?
310-
.byte_range();
311-
Some((range_to_replace, replacement.to_string()))
312-
}
313-
314-
static STRING_OF_ARRAY_REPLACE: LazyLock<HashMap<&str, &str>> =
315-
LazyLock::new(|| HashMap::from_iter([("editor::GoToPrevHunk", "editor::GoToPreviousHunk")]));
316-
317268
const ACTION_ARGUMENT_OBJECT_PATTERN: &str = r#"(document
318269
(array
319270
(object
@@ -485,6 +436,7 @@ static STRING_REPLACE: LazyLock<HashMap<&str, &str>> = LazyLock::new(|| {
485436
("pane::ActivatePrevItem", "pane::ActivatePreviousItem"),
486437
("vim::MoveToPrev", "vim::MoveToPrevious"),
487438
("vim::MoveToPrevMatch", "vim::MoveToPreviousMatch"),
439+
("editor::GoToPrevHunk", "editor::GoToPreviousHunk"),
488440
])
489441
});
490442

@@ -926,36 +878,6 @@ mod tests {
926878
)
927879
}
928880

929-
#[test]
930-
fn test_string_of_array_replace() {
931-
assert_migrate_keymap(
932-
r#"
933-
[
934-
{
935-
"bindings": {
936-
"ctrl-p": ["editor::GoToPrevHunk", { "center_cursor": true }],
937-
"ctrl-q": ["editor::GoToPrevHunk"],
938-
"ctrl-q": "editor::GoToPrevHunk", // should remain same
939-
}
940-
}
941-
]
942-
"#,
943-
Some(
944-
r#"
945-
[
946-
{
947-
"bindings": {
948-
"ctrl-p": ["editor::GoToPreviousHunk", { "center_cursor": true }],
949-
"ctrl-q": ["editor::GoToPreviousHunk"],
950-
"ctrl-q": "editor::GoToPrevHunk", // should remain same
951-
}
952-
}
953-
]
954-
"#,
955-
),
956-
)
957-
}
958-
959881
#[test]
960882
fn test_action_argument_snake_case() {
961883
// First performs transformations, then replacements

0 commit comments

Comments
 (0)