From 72c6a7450558fc4a1026fa10f846c1236fd9ee27 Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Mon, 27 Oct 2025 06:56:54 -0700 Subject: [PATCH] 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 --- crates/settings/src/keymap_file.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/settings/src/keymap_file.rs b/crates/settings/src/keymap_file.rs index b69b498a6c5596d8bbc78799e8edbe0befc9c35e..5737655924830a479756a699ff638a70f4925c07 100644 --- a/crates/settings/src/keymap_file.rs +++ b/crates/settings/src/keymap_file.rs @@ -150,6 +150,9 @@ pub enum KeymapFileLoadResult { impl KeymapFile { pub fn parse(content: &str) -> anyhow::Result { + if content.trim().is_empty() { + return Ok(Self(Vec::new())); + } parse_json_with_comments::(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) => {