mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 09:01:20 +00:00
fix(tui): handle split Shift+Enter in VS Code
This commit is contained in:
parent
f0fd0a7d6a
commit
178a3a563f
4 changed files with 84 additions and 0 deletions
|
|
@ -275,6 +275,26 @@ describe("Editor component", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("Shift+Enter handling", () => {
|
||||
it("treats split VS Code Shift+Enter as a newline", () => {
|
||||
const editor = new Editor(defaultEditorTheme);
|
||||
|
||||
editor.handleInput("\\");
|
||||
editor.handleInput("\r");
|
||||
|
||||
assert.strictEqual(editor.getText(), "\n");
|
||||
});
|
||||
|
||||
it("inserts a literal backslash when not followed by Enter", () => {
|
||||
const editor = new Editor(defaultEditorTheme);
|
||||
|
||||
editor.handleInput("\\");
|
||||
editor.handleInput("x");
|
||||
|
||||
assert.strictEqual(editor.getText(), "\\x");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Unicode text editing behavior", () => {
|
||||
it("inserts mixed ASCII, umlauts, and emojis as literal text", () => {
|
||||
const editor = new Editor(defaultEditorTheme);
|
||||
|
|
|
|||
30
packages/tui/test/input.test.ts
Normal file
30
packages/tui/test/input.test.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import assert from "node:assert";
|
||||
import { describe, it } from "node:test";
|
||||
import { Input } from "../src/components/input.js";
|
||||
|
||||
describe("Input component", () => {
|
||||
it("treats split VS Code Shift+Enter as submit", () => {
|
||||
const input = new Input();
|
||||
let submitted: string | undefined;
|
||||
|
||||
input.setValue("hello");
|
||||
input.onSubmit = (value) => {
|
||||
submitted = value;
|
||||
};
|
||||
|
||||
input.handleInput("\\");
|
||||
input.handleInput("\r");
|
||||
|
||||
assert.strictEqual(submitted, "hello");
|
||||
assert.strictEqual(input.getValue(), "hello");
|
||||
});
|
||||
|
||||
it("inserts a literal backslash when not followed by Enter", () => {
|
||||
const input = new Input();
|
||||
|
||||
input.handleInput("\\");
|
||||
input.handleInput("x");
|
||||
|
||||
assert.strictEqual(input.getValue(), "\\x");
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue