From 84ae335dfab29cea2227ffea48bcaebdd10482ad Mon Sep 17 00:00:00 2001 From: 844196 <844196@users.noreply.github.com> Date: Sat, 26 Jul 2025 04:21:56 +0900 Subject: [PATCH 1/4] :art: (run): Remove unnecessary catches --- src/run.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/run.ts b/src/run.ts index 6dfb349..b075d34 100644 --- a/src/run.ts +++ b/src/run.ts @@ -41,8 +41,8 @@ For example, this simulates pressing "g", "p", and "f".`, })() const fetchBindingsWaiting = Promise.all([ - loadYaml(joinPath(XDG_CONFIG_HOME, 'wk', 'bindings.yaml')).catch(() => []).catch(() => []), - loadYaml(joinPath(Deno.cwd(), 'wk.bindings.yaml')).catch(() => []).catch(() => []), + loadYaml(joinPath(XDG_CONFIG_HOME, 'wk', 'bindings.yaml')).catch(() => [] as Binding[]), + loadYaml(joinPath(Deno.cwd(), 'wk.bindings.yaml')).catch(() => [] as Binding[]), ]).then(([globalBindings, localBindings]) => [...globalBindings, ...localBindings]) const tty = await Deno.open('/dev/tty', { read: true, write: true }) From e3ac174d2f887006b2113398f58503ad0c5ebf12 Mon Sep 17 00:00:00 2001 From: 844196 <844196@users.noreply.github.com> Date: Sat, 26 Jul 2025 04:22:53 +0900 Subject: [PATCH 2/4] :zap: (run): Use concat instead of spread operator --- src/run.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/run.ts b/src/run.ts index b075d34..3b1e4d4 100644 --- a/src/run.ts +++ b/src/run.ts @@ -43,7 +43,7 @@ For example, this simulates pressing "g", "p", and "f".`, const fetchBindingsWaiting = Promise.all([ loadYaml(joinPath(XDG_CONFIG_HOME, 'wk', 'bindings.yaml')).catch(() => [] as Binding[]), loadYaml(joinPath(Deno.cwd(), 'wk.bindings.yaml')).catch(() => [] as Binding[]), - ]).then(([globalBindings, localBindings]) => [...globalBindings, ...localBindings]) + ]).then(([globalBindings, localBindings]) => globalBindings.concat(localBindings)) const tty = await Deno.open('/dev/tty', { read: true, write: true }) const tui = new TUI(tty, inputs === undefined ? [] : inputs.split(' ').map(unescapeAnsi)) From 85183fad287ae0a4b4386a0cd9f4d1d6430017d1 Mon Sep 17 00:00:00 2001 From: 844196 <844196@users.noreply.github.com> Date: Sat, 26 Jul 2025 04:42:57 +0900 Subject: [PATCH 3/4] :recycle: (const): Define and use `WK_CONFIG_HOME` --- src/const.ts | 3 ++- src/run.ts | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/const.ts b/src/const.ts index 71bb4ad..0c83058 100644 --- a/src/const.ts +++ b/src/const.ts @@ -1,5 +1,6 @@ import { xdgConfig } from 'xdg-basedir' +import { join as joinPath } from '@std/path' -export const XDG_CONFIG_HOME = xdgConfig ?? Deno.makeTempDirSync() +export const WK_CONFIG_HOME = joinPath(xdgConfig ?? Deno.makeTempDirSync(), 'wk') export const PRINTABLE_ASCII = /^[ -~]$/ diff --git a/src/run.ts b/src/run.ts index 3b1e4d4..5102b8f 100644 --- a/src/run.ts +++ b/src/run.ts @@ -2,7 +2,7 @@ import { Command, EnumType } from '@cliffy/command' import { join as joinPath } from '@std/path' import { parse as parseYaml } from '@std/yaml' import { Binding } from './types/Binding.ts' -import { XDG_CONFIG_HOME } from './const.ts' +import { WK_CONFIG_HOME } from './const.ts' import { TUI } from './tui.ts' import { defaultContext, mergeContext, PartialContext } from './types/Context.ts' import { Dependencies, main } from './main.ts' @@ -31,9 +31,7 @@ For example, this simulates pressing "g", "p", and "f".`, ) .action(async ({ upOneLine, inputs }) => { const fetchContextWaiting = (async () => { - const found = await loadYaml(joinPath(XDG_CONFIG_HOME, 'wk', 'config.yaml')).catch(() => - undefined - ) + const found = await loadYaml(joinPath(WK_CONFIG_HOME, 'config.yaml')).catch(() => undefined) if (found === undefined) { return defaultContext } @@ -41,7 +39,7 @@ For example, this simulates pressing "g", "p", and "f".`, })() const fetchBindingsWaiting = Promise.all([ - loadYaml(joinPath(XDG_CONFIG_HOME, 'wk', 'bindings.yaml')).catch(() => [] as Binding[]), + loadYaml(joinPath(WK_CONFIG_HOME, 'bindings.yaml')).catch(() => [] as Binding[]), loadYaml(joinPath(Deno.cwd(), 'wk.bindings.yaml')).catch(() => [] as Binding[]), ]).then(([globalBindings, localBindings]) => globalBindings.concat(localBindings)) From c4fb29bab2d99b9aa4cd59f749daea6e407d3bd5 Mon Sep 17 00:00:00 2001 From: 844196 <844196@users.noreply.github.com> Date: Sat, 26 Jul 2025 04:46:27 +0900 Subject: [PATCH 4/4] :recycle: (init, widget): Exclude implementation details comments from outputs --- src/widget.eta | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/widget.eta b/src/widget.eta index 4f9097d..63cfbf7 100644 --- a/src/widget.eta +++ b/src/widget.eta @@ -28,8 +28,8 @@ _wk_widget() { ;; esac - # `p` flag does NOT work with the ${var} format; must use $var instead. - # See: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion + <%- /* `p` flag does NOT work with the ${var} format; must use $var instead. */ _%> + <%- /* See: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion */ _%> local delimiter=$res[1] reply=("${(@ps:$delimiter:)${res:2}}")