Use '*' to represent the default context in keymap files
Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
parent
ee3eb9658f
commit
add0dad6d7
2 changed files with 7 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"": {
|
"*": {
|
||||||
"ctrl-alt-cmd-f": "workspace::FollowNextCollaborator",
|
"ctrl-alt-cmd-f": "workspace::FollowNextCollaborator",
|
||||||
"cmd-s": "workspace::Save",
|
"cmd-s": "workspace::Save",
|
||||||
"cmd-alt-i": "workspace::DebugElements",
|
"cmd-alt-i": "workspace::DebugElements",
|
||||||
|
|
|
@ -29,16 +29,17 @@ impl KeymapFile {
|
||||||
|
|
||||||
pub fn add(self, cx: &mut MutableAppContext) -> Result<()> {
|
pub fn add(self, cx: &mut MutableAppContext) -> Result<()> {
|
||||||
for (context, actions) in self.0 {
|
for (context, actions) in self.0 {
|
||||||
let context = if context.is_empty() {
|
let context = if context == "*" { None } else { Some(context) };
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(context)
|
|
||||||
};
|
|
||||||
cx.add_bindings(
|
cx.add_bindings(
|
||||||
actions
|
actions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(keystroke, action)| {
|
.map(|(keystroke, action)| {
|
||||||
let action = action.get();
|
let action = action.get();
|
||||||
|
|
||||||
|
// This is a workaround for a limitation in serde: serde-rs/json#497
|
||||||
|
// We want to deserialize the action data as a `RawValue` so that we can
|
||||||
|
// deserialize the action itself dynamically directly from the JSON
|
||||||
|
// string. But `RawValue` currently does not work inside of an untagged enum.
|
||||||
let action = if action.starts_with('[') {
|
let action = if action.starts_with('[') {
|
||||||
let ActionWithData(name, data) = serde_json::from_str(action)?;
|
let ActionWithData(name, data) = serde_json::from_str(action)?;
|
||||||
cx.deserialize_action(name, Some(data.get()))
|
cx.deserialize_action(name, Some(data.get()))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue