summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam <[email protected]>2025-12-16 15:10:38 -0600
committerAdam <[email protected]>2025-12-16 15:10:44 -0600
commit9aa5460a0e1292dbfa6abcf944e8f5982618f3ca (patch)
tree41516d57d0f1320bff9cab9d1cadac1e3341d9f9
parentb4014e5baabfa0a404464cf71c153c8dbbe7ac65 (diff)
downloadopencode-9aa5460a0e1292dbfa6abcf944e8f5982618f3ca.tar.gz
opencode-9aa5460a0e1292dbfa6abcf944e8f5982618f3ca.zip
fix(desktop): prompt history navigation
-rw-r--r--packages/desktop/src/components/prompt-input.tsx15
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/desktop/src/components/prompt-input.tsx b/packages/desktop/src/components/prompt-input.tsx
index 6bd3127be..a04211a98 100644
--- a/packages/desktop/src/components/prompt-input.tsx
+++ b/packages/desktop/src/components/prompt-input.tsx
@@ -593,23 +593,24 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
if (event.key === "ArrowUp" || event.key === "ArrowDown") {
if (event.altKey || event.ctrlKey || event.metaKey) return
- const { collapsed, cursorPosition, textLength } = getCaretState()
+ const { collapsed } = getCaretState()
if (!collapsed) return
+
+ const cursorPosition = getCursorPosition(editorRef)
+ const textLength = promptLength(prompt.current())
const inHistory = store.historyIndex >= 0
- const atAbsoluteStart = cursorPosition === 0
- const atAbsoluteEnd = cursorPosition === textLength
- const allowUp = (inHistory && atAbsoluteEnd) || atAbsoluteStart
- const allowDown = (inHistory && atAbsoluteStart) || atAbsoluteEnd
+ const atStart = cursorPosition <= 0
+ const atEnd = cursorPosition >= textLength
if (event.key === "ArrowUp") {
- if (!allowUp) return
+ if (!atStart && !(inHistory && atEnd)) return
if (navigateHistory("up")) {
event.preventDefault()
}
return
}
- if (!allowDown) return
+ if (!atEnd && !(inHistory && atStart)) return
if (navigateHistory("down")) {
event.preventDefault()
}