Squashed 'src/pi/' content from commit d981de122
git-subtree-dir: src/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { setKeybindings, TuiMainScreen } from "@earendil-works/pi-tui";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { defaultEditorTheme } from "../../tui/test/test-themes.ts";
|
||||
import { VirtualTerminal } from "../../tui/test/virtual-terminal.ts";
|
||||
import { KeybindingsManager } from "../src/core/keybindings.ts";
|
||||
import { CustomEditor } from "../src/modes/interactive/components/custom-editor.ts";
|
||||
|
||||
afterEach(() => {
|
||||
setKeybindings(new KeybindingsManager());
|
||||
});
|
||||
|
||||
describe("CustomEditor prompt history keybindings", () => {
|
||||
it("gives an explicit history binding precedence over model cycling", () => {
|
||||
const keybindings = new KeybindingsManager({
|
||||
"tui.editor.historyPrevious": "ctrl+p",
|
||||
"tui.editor.historyNext": "ctrl+n",
|
||||
});
|
||||
setKeybindings(keybindings);
|
||||
const editor = new CustomEditor(new TuiMainScreen(new VirtualTerminal()), defaultEditorTheme, keybindings);
|
||||
let modelCycles = 0;
|
||||
editor.onAction("app.model.cycleForward", () => {
|
||||
modelCycles++;
|
||||
});
|
||||
editor.addToHistory("previous prompt");
|
||||
editor.setText("draft");
|
||||
|
||||
editor.handleInput("\x10"); // Ctrl+P
|
||||
expect(editor.getText()).toBe("previous prompt");
|
||||
expect(modelCycles).toBe(0);
|
||||
|
||||
editor.handleInput("\x0e"); // Ctrl+N
|
||||
expect(editor.getText()).toBe("draft");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user