From c216e15e99a4c89229bde65f1d81f4dda95f20ac Mon Sep 17 00:00:00 2001 From: Ariane Emory Date: Mon, 9 Mar 2026 09:07:47 -0400 Subject: [PATCH] fix: remove cursor position checks from history navigation keys History navigation (Alt+P/Alt+N) now works immediately on first keystroke regardless of cursor position. Cursor is placed at end of input after navigation, matching standard shell behavior. --- .../src/cli/cmd/tui/component/prompt/index.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx index d63c248fb83..ee66ac803a6 100644 --- a/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx @@ -886,10 +886,7 @@ export function Prompt(props: PromptProps) { } if (store.mode === "normal") autocomplete.onKeyDown(e) if (!autocomplete.visible) { - if ( - (keybind.match("history_previous", e) && input.cursorOffset === 0) || - (keybind.match("history_next", e) && input.cursorOffset === input.plainText.length) - ) { + if (keybind.match("history_previous", e) || keybind.match("history_next", e)) { const direction = keybind.match("history_previous", e) ? -1 : 1 const item = history.move(direction, input.plainText) @@ -899,15 +896,10 @@ export function Prompt(props: PromptProps) { setStore("mode", item.mode ?? "normal") restoreExtmarksFromParts(item.parts) e.preventDefault() - if (direction === -1) input.cursorOffset = 0 - if (direction === 1) input.cursorOffset = input.plainText.length + input.cursorOffset = input.plainText.length } return } - - if (keybind.match("history_previous", e) && input.visualCursor.visualRow === 0) input.cursorOffset = 0 - if (keybind.match("history_next", e) && input.visualCursor.visualRow === input.height - 1) - input.cursorOffset = input.plainText.length } }} onSubmit={submit}