From 0cfcc00912f0a928439f3abce54eba03be8098d9 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 6 Nov 2020 11:51:36 +0000 Subject: [PATCH] Desktop: Fixes #4049: Keymap editor crash when an invalid command is used --- ElectronClient/gui/KeymapConfig/utils/getLabel.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ElectronClient/gui/KeymapConfig/utils/getLabel.ts b/ElectronClient/gui/KeymapConfig/utils/getLabel.ts index a0a20fe576..b25d66fbcf 100644 --- a/ElectronClient/gui/KeymapConfig/utils/getLabel.ts +++ b/ElectronClient/gui/KeymapConfig/utils/getLabel.ts @@ -30,9 +30,14 @@ const getLabel = (commandName: string):string => { return _('Command palette'); case 'config': return shim.isMac() ? _('Preferences') : _('Options'); - default: - throw new Error(`Command: ${commandName} is unknown`); } + + // We don't throw an error if a command is not found because if for + // example a command is removed from one version to the next, or a + // command is renamed, we still want the keymap editor to work. So in + // that case, we simply display the command name and it is up to the + // user to fix the shortcut if needed. + return `${commandName} (${_('Invalid')})`; }; export default getLabel;