fix(tui): remove backslash input buffering (#1037)

Instead of buffering `\` and waiting for the next key, let it be
inserted immediately. On Enter, check if preceded by `\` and treat as
newline.

Removed backslash handling from the Input component entirely.
This commit is contained in:
Sviatoslav Abakumov 2026-01-29 05:47:15 +04:00 committed by GitHub
parent bac57f81be
commit d57a26c88b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 61 additions and 43 deletions

View file

@ -3,23 +3,28 @@ 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", () => {
it("submits value including backslash on Enter", () => {
const input = new Input();
let submitted: string | undefined;
input.setValue("hello");
input.onSubmit = (value) => {
submitted = value;
};
// Type hello, then backslash, then Enter
input.handleInput("h");
input.handleInput("e");
input.handleInput("l");
input.handleInput("l");
input.handleInput("o");
input.handleInput("\\");
input.handleInput("\r");
assert.strictEqual(submitted, "hello");
assert.strictEqual(input.getValue(), "hello");
// Input is single-line, no backslash+Enter workaround
assert.strictEqual(submitted, "hello\\");
});
it("inserts a literal backslash when not followed by Enter", () => {
it("inserts backslash as regular character", () => {
const input = new Input();
input.handleInput("\\");