Skip to content

Commit

Permalink
feat: make setupShortcut homogeneous for chained and default
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Previous code that redefines shortcuts will remove all default ones.
  • Loading branch information
twitwi committed Sep 3, 2022
1 parent a2887e8 commit 40e872e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/client/logic/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ export function strokeShortcut(key: KeyFilter, fn: Fn) {
}

export function registerShortcuts() {
const { customShortcuts, defaultShortcuts } = setupShortcuts()
const allShortcuts = setupShortcuts()

const shortcuts = new Map<string | Ref<Boolean>, ShortcutOptions>(
[...defaultShortcuts, ...customShortcuts].map((options: ShortcutOptions) => [options.key, options]),
allShortcuts.map((options: ShortcutOptions) => [options.key, options]),
)

shortcuts.forEach((options) => {
Expand Down
8 changes: 3 additions & 5 deletions packages/client/setup/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default function setupShortcuts() {
showGotoDialog: () => showGotoDialog.value = !showGotoDialog.value,
}

const injection_arg_2: ShortcutOptions[] = [
// eslint-disable-next-line prefer-const
let injection_return: ShortcutOptions[] = [
{ name: 'next_space', key: and(space, not(shift)), fn: next, autoRepeat: true },
{ name: 'prev_space', key: and(space, shift), fn: prev, autoRepeat: true },
{ name: 'next_right', key: and(right, not(shift), not(showOverview)), fn: next, autoRepeat: true },
Expand All @@ -50,10 +51,7 @@ export default function setupShortcuts() {
{ name: 'goto_from_overview', key: and(enter, showOverview), fn: () => { go(currentOverviewPage.value); showOverview.value = false } },
]

// eslint-disable-next-line prefer-const
let injection_return: Array<ShortcutOptions> = []

/* __chained_injections__ */

return { customShortcuts: injection_return, defaultShortcuts: injection_arg_2 }
return injection_return
}

0 comments on commit 40e872e

Please sign in to comment.