summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/components/prompt-input/history.test.ts
diff options
context:
space:
mode:
authorAdam <[email protected]>2026-02-12 19:58:43 -0600
committerAdam <[email protected]>2026-02-12 19:58:57 -0600
commit7f95cc64c57b439f58833d0300a1da93b3b893df (patch)
treed9a75b27dac2f1fcf5865bb3c98fbee28f489eb5 /packages/app/src/components/prompt-input/history.test.ts
parentb525c03d205e37ad7527e6bd1749b324395dd6b7 (diff)
downloadopencode-7f95cc64c57b439f58833d0300a1da93b3b893df.tar.gz
opencode-7f95cc64c57b439f58833d0300a1da93b3b893df.zip
fix(app): prompt input quirks
Diffstat (limited to 'packages/app/src/components/prompt-input/history.test.ts')
-rw-r--r--packages/app/src/components/prompt-input/history.test.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/app/src/components/prompt-input/history.test.ts b/packages/app/src/components/prompt-input/history.test.ts
index 54be9cb75..a37fdad67 100644
--- a/packages/app/src/components/prompt-input/history.test.ts
+++ b/packages/app/src/components/prompt-input/history.test.ts
@@ -1,6 +1,12 @@
import { describe, expect, test } from "bun:test"
import type { Prompt } from "@/context/prompt"
-import { clonePromptParts, navigatePromptHistory, prependHistoryEntry, promptLength } from "./history"
+import {
+ canNavigateHistoryAtCursor,
+ clonePromptParts,
+ navigatePromptHistory,
+ prependHistoryEntry,
+ promptLength,
+} from "./history"
const DEFAULT_PROMPT: Prompt = [{ type: "text", content: "", start: 0, end: 0 }]
@@ -66,4 +72,20 @@ describe("prompt-input history", () => {
if (original[1]?.type !== "file") throw new Error("expected file")
expect(original[1].selection?.startLine).toBe(1)
})
+
+ test("canNavigateHistoryAtCursor only allows multiline boundaries", () => {
+ const value = "a\nb\nc"
+
+ expect(canNavigateHistoryAtCursor("up", value, 0)).toBe(true)
+ expect(canNavigateHistoryAtCursor("down", value, 0)).toBe(false)
+
+ expect(canNavigateHistoryAtCursor("up", value, 2)).toBe(false)
+ expect(canNavigateHistoryAtCursor("down", value, 2)).toBe(false)
+
+ expect(canNavigateHistoryAtCursor("up", value, 5)).toBe(false)
+ expect(canNavigateHistoryAtCursor("down", value, 5)).toBe(true)
+
+ expect(canNavigateHistoryAtCursor("up", "abc", 1)).toBe(true)
+ expect(canNavigateHistoryAtCursor("down", "abc", 1)).toBe(true)
+ })
})