Replace unset unknown keybinding error with warn (#2186)

This commit is contained in:
Chenlei Hu
2025-01-07 10:33:23 -05:00
committed by GitHub
parent 90698fced6
commit ea6c9e7ca5
2 changed files with 19 additions and 1 deletions

View File

@@ -227,7 +227,7 @@ export const useKeybindingStore = defineStore('keybinding', () => {
return
}
throw new Error(`Unknown keybinding: ${JSON.stringify(keybinding)}`)
console.warn(`Unset unknown keybinding: ${JSON.stringify(keybinding)}`)
}
/**

View File

@@ -149,6 +149,24 @@ describe('useKeybindingStore', () => {
expect(() => store.unsetKeybinding(keybinding)).not.toThrow()
})
it('should not throw an error when unsetting unknown keybinding', () => {
const store = useKeybindingStore()
const keybinding = new KeybindingImpl({
commandId: 'test.command',
combo: { key: 'I', ctrl: true }
})
store.addUserKeybinding(keybinding)
expect(() =>
store.unsetKeybinding(
new KeybindingImpl({
commandId: 'test.foo',
combo: { key: 'I', ctrl: true }
})
)
).not.toThrow()
})
it('should remove unset keybinding when adding back a default keybinding', () => {
const store = useKeybindingStore()
const defaultKeybinding = new KeybindingImpl({