keymap_ui: Replace zed::NoAction with null (#34562)

Closes #ISSUE

This change applies both to the UI (we render `<null>` as muted text
instead of `zed::NoAction`) as well as how we update the keymap file
(the duplicated binding is bound to `null` instead of `"zed::NoAction"`)

Release Notes:

- N/A *or* Added/Fixed/Improved ...
This commit is contained in:
Ben Kunkle 2025-07-16 12:55:58 -05:00 committed by GitHub
parent 048dc47d87
commit 573836a654
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 75 additions and 15 deletions

View file

@ -881,6 +881,9 @@ pub struct KeybindUpdateTarget<'a> {
impl<'a> KeybindUpdateTarget<'a> {
fn action_value(&self) -> Result<Value> {
if self.action_name == gpui::NoAction.name() {
return Ok(Value::Null);
}
let action_name: Value = self.action_name.into();
let value = match self.action_arguments {
Some(args) => {
@ -1479,10 +1482,6 @@ mod tests {
]"#
.unindent(),
);
}
#[test]
fn test_append() {
check_keymap_update(
r#"[
{
@ -1529,5 +1528,43 @@ mod tests {
]"#
.unindent(),
);
check_keymap_update(
r#"[
{
"context": "SomeOtherContext",
"use_key_equivalents": true,
"bindings": {
"b": "foo::bar",
}
},
]"#
.unindent(),
KeybindUpdateOperation::Remove {
target: KeybindUpdateTarget {
context: Some("SomeContext"),
keystrokes: &parse_keystrokes("a"),
action_name: "foo::baz",
action_arguments: Some("true"),
},
target_keybind_source: KeybindSource::Default,
},
r#"[
{
"context": "SomeOtherContext",
"use_key_equivalents": true,
"bindings": {
"b": "foo::bar",
}
},
{
"context": "SomeContext",
"bindings": {
"a": null
}
}
]"#
.unindent(),
);
}
}