Skip to content

Commit f043bf4

Browse files
authored
Fixes anomalyco#7056 ctrl+j and ctrl+k for vim-style dialog list navigation.
1 parent 66a5655 commit f043bf4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/opencode/src/cli/cmd/tui/ui/dialog-select.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,13 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
187187
useKeyboard((evt) => {
188188
setStore("input", "keyboard")
189189

190-
if (evt.name === "up" || (evt.ctrl && evt.name === "p")) move(-1)
191-
if (evt.name === "down" || (evt.ctrl && evt.name === "n")) move(1)
190+
if (evt.name === "up" || (evt.ctrl && evt.name === "p") || (evt.ctrl && evt.name === "k")) move(-1)
191+
if (evt.name === "down" ||
192+
(evt.ctrl && evt.name === "n") ||
193+
(evt.ctrl && evt.name === "j") ||
194+
evt.name === "linefeed") // "linefeed" needed for tmux compatibility.
195+
move(1)
196+
192197
if (evt.name === "pageup") move(-10)
193198
if (evt.name === "pagedown") move(10)
194199
if (evt.name === "home") moveTo(0)
@@ -242,6 +247,10 @@ export function DialogSelect<T>(props: DialogSelectProps<T>) {
242247
</box>
243248
<box paddingTop={1}>
244249
<input
250+
onKeyDown={(e) => {
251+
// Default handling for movement ctrl+k would prevent custom handling like theme previewing.
252+
if (e.ctrl && e.name === "k") e.preventDefault()
253+
}}
245254
onInput={(e) => {
246255
batch(() => {
247256
setStore("filter", e)

0 commit comments

Comments
 (0)