Skip to content

Commit

Permalink
fix: commands may undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
kvoon3 committed Sep 13, 2024
1 parent 95748ad commit edd9466
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,19 @@ export const { activate, deactivate } = defineExtension(async () => {
return undefined
})

await updateConfig()

useCommand(Meta.commands.show, () => {
logger.info('VimMode', VimMode.value)
logger.info(`show ${whichKeyBindings.value}`)
commands.executeCommand('whichkey.show', whichKeyBindings.value)
})
useCommand(Meta.commands.updateConfig, async () => await updateConfig())
useCommand(Meta.commands.toggleEnable, async () => configs.enable.value = !configs.enable.value)
try {
await updateConfig()
}
catch (error) {
logger.error(error)
}
finally {
useCommand(Meta.commands.show, () => {
logger.info('VimMode', VimMode.value)
logger.info(`show ${whichKeyBindings.value}`)
commands.executeCommand('whichkey.show', whichKeyBindings.value)
})
useCommand(Meta.commands.updateConfig, async () => await updateConfig())
useCommand(Meta.commands.toggleEnable, async () => configs.enable.value = !configs.enable.value)
}
})
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export function genWhichKeyTree(keys: string[], commands: string[], names: strin
export function vim2whichkey(vimKeybindings: VimKeybinding[]): WhichKeyItem[] {
return vimKeybindings
.filter(keybinding =>
!keybinding?.commands.includes('whichkey.show')
&& !keybinding?.commands.includes('whichKeyConfigGen.show')
!keybinding?.commands?.includes('whichkey.show')
&& !keybinding?.commands?.includes('whichKeyConfigGen.show')
&& keybinding.before[0] === 'leader',
)
.reduce((whichKeyBindings, vimKeybinding) => {
Expand Down

0 comments on commit edd9466

Please sign in to comment.