Display keymap errors on initial load (#23394)
Also fixes issue introduced in #23113 where changes to keyboard layout would not cause reload of keymap configuration. Closes #20531 Release Notes: - N/A
This commit is contained in:
parent
04c04e8406
commit
cc1af7d96b
3 changed files with 147 additions and 82 deletions
|
@ -119,9 +119,6 @@ pub enum KeymapFileLoadResult {
|
|||
key_bindings: Vec<KeyBinding>,
|
||||
error_message: MarkdownString,
|
||||
},
|
||||
AllFailedToLoad {
|
||||
error_message: MarkdownString,
|
||||
},
|
||||
JsonParseFailure {
|
||||
error: anyhow::Error,
|
||||
},
|
||||
|
@ -135,8 +132,7 @@ impl KeymapFile {
|
|||
pub fn load_asset(asset_path: &str, cx: &AppContext) -> anyhow::Result<Vec<KeyBinding>> {
|
||||
match Self::load(asset_str::<SettingsAssets>(asset_path).as_ref(), cx) {
|
||||
KeymapFileLoadResult::Success { key_bindings, .. } => Ok(key_bindings),
|
||||
KeymapFileLoadResult::SomeFailedToLoad { error_message, .. }
|
||||
| KeymapFileLoadResult::AllFailedToLoad { error_message } => Err(anyhow!(
|
||||
KeymapFileLoadResult::SomeFailedToLoad { error_message, .. } => Err(anyhow!(
|
||||
"Error loading built-in keymap \"{asset_path}\": {error_message}"
|
||||
)),
|
||||
KeymapFileLoadResult::JsonParseFailure { error } => Err(anyhow!(
|
||||
|
@ -151,11 +147,14 @@ impl KeymapFile {
|
|||
cx: &AppContext,
|
||||
) -> anyhow::Result<Vec<KeyBinding>> {
|
||||
match Self::load(asset_str::<SettingsAssets>(asset_path).as_ref(), cx) {
|
||||
KeymapFileLoadResult::Success { key_bindings, .. }
|
||||
| KeymapFileLoadResult::SomeFailedToLoad { key_bindings, .. } => Ok(key_bindings),
|
||||
KeymapFileLoadResult::AllFailedToLoad { error_message } => Err(anyhow!(
|
||||
KeymapFileLoadResult::SomeFailedToLoad {
|
||||
key_bindings,
|
||||
error_message,
|
||||
} if key_bindings.is_empty() => Err(anyhow!(
|
||||
"Error loading built-in keymap \"{asset_path}\": {error_message}"
|
||||
)),
|
||||
KeymapFileLoadResult::Success { key_bindings, .. }
|
||||
| KeymapFileLoadResult::SomeFailedToLoad { key_bindings, .. } => Ok(key_bindings),
|
||||
KeymapFileLoadResult::JsonParseFailure { error } => Err(anyhow!(
|
||||
"JSON parse error in built-in keymap \"{asset_path}\": {error}"
|
||||
)),
|
||||
|
@ -166,8 +165,7 @@ impl KeymapFile {
|
|||
pub fn load_panic_on_failure(content: &str, cx: &AppContext) -> Vec<KeyBinding> {
|
||||
match Self::load(content, cx) {
|
||||
KeymapFileLoadResult::Success { key_bindings } => key_bindings,
|
||||
KeymapFileLoadResult::SomeFailedToLoad { error_message, .. }
|
||||
| KeymapFileLoadResult::AllFailedToLoad { error_message, .. } => {
|
||||
KeymapFileLoadResult::SomeFailedToLoad { error_message, .. } => {
|
||||
panic!("{error_message}");
|
||||
}
|
||||
KeymapFileLoadResult::JsonParseFailure { error } => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue