chore(vendor): import pi 0.85.1
Imported as a linear vendor commit so forge rebases do not replay the upstream root tree. git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
1 parent
5ebc7018c3
commit
4def357d09
1669 files changed
+397627
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import assert from "node:assert";
|
||||
import { afterEach, describe, it } from "node:test";
|
||||
import { Editor } from "../src/components/editor.ts";
|
||||
import { KeybindingsManager, setKeybindings, TUI_KEYBINDINGS } from "../src/keybindings.ts";
|
||||
import { TuiMainScreen } from "../src/tui-main-screen.ts";
|
||||
import { defaultEditorTheme } from "./test-themes.ts";
|
||||
import { VirtualTerminal } from "./virtual-terminal.ts";
|
||||
|
||||
afterEach(() => {
|
||||
setKeybindings(new KeybindingsManager(TUI_KEYBINDINGS));
|
||||
});
|
||||
|
||||
describe("Editor prompt history keybindings", () => {
|
||||
it("browses history directly without first moving the cursor", () => {
|
||||
setKeybindings(
|
||||
new KeybindingsManager(TUI_KEYBINDINGS, {
|
||||
"tui.editor.historyPrevious": "ctrl+p",
|
||||
"tui.editor.historyNext": "ctrl+n",
|
||||
}),
|
||||
);
|
||||
const editor = new Editor(new TuiMainScreen(new VirtualTerminal()), defaultEditorTheme);
|
||||
editor.addToHistory("older prompt");
|
||||
editor.addToHistory("newer\nmultiline prompt");
|
||||
editor.setText("draft");
|
||||
editor.handleInput("\x1b[D");
|
||||
editor.handleInput("\x1b[D");
|
||||
|
||||
editor.handleInput("\x10"); // Ctrl+P
|
||||
assert.strictEqual(editor.getText(), "newer\nmultiline prompt");
|
||||
assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 0 });
|
||||
|
||||
editor.handleInput("\x10"); // Ctrl+P
|
||||
assert.strictEqual(editor.getText(), "older prompt");
|
||||
|
||||
editor.handleInput("\x0e"); // Ctrl+N
|
||||
assert.strictEqual(editor.getText(), "newer\nmultiline prompt");
|
||||
assert.deepStrictEqual(editor.getCursor(), { line: 1, col: 16 });
|
||||
|
||||
editor.handleInput("\x0e"); // Ctrl+N
|
||||
assert.strictEqual(editor.getText(), "draft");
|
||||
assert.deepStrictEqual(editor.getCursor(), { line: 0, col: 3 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user