mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
keymap_editor: Fix updating empty keymap (#40909)
Closes #40898 Release Notes: - Fixed an issue where attempting to add or update a key binding in the keymap editor with an empty `keymap.json` file would fail
This commit is contained in:
parent
941033e373
commit
72c6a74505
1 changed files with 3 additions and 5 deletions
|
|
@ -150,6 +150,9 @@ pub enum KeymapFileLoadResult {
|
|||
|
||||
impl KeymapFile {
|
||||
pub fn parse(content: &str) -> anyhow::Result<Self> {
|
||||
if content.trim().is_empty() {
|
||||
return Ok(Self(Vec::new()));
|
||||
}
|
||||
parse_json_with_comments::<Self>(content)
|
||||
}
|
||||
|
||||
|
|
@ -211,11 +214,6 @@ impl KeymapFile {
|
|||
}
|
||||
|
||||
pub fn load(content: &str, cx: &App) -> KeymapFileLoadResult {
|
||||
if content.is_empty() {
|
||||
return KeymapFileLoadResult::Success {
|
||||
key_bindings: Vec::new(),
|
||||
};
|
||||
}
|
||||
let keymap_file = match Self::parse(content) {
|
||||
Ok(keymap_file) => keymap_file,
|
||||
Err(error) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue