feat: rewrite stdin pipeline with input-parser, exitOnCtrlC via \x03
- Replace data event with readable + input-parser state machine - Intercept \x03 in input pipeline (not process SIGINT) - useInput now uses parse-keypress for semantic key mapping - 20ms pending escape flush timer matching Ink - Esc focus reset in input pipeline - Delete old key-parser.ts (replaced by input-parser + parse-keypress) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { defineComponent, shallowRef } from "vue";
|
||||
import { expect, test } from "vite-plus/test";
|
||||
import { expect, test, vi } from "vite-plus/test";
|
||||
import { render } from "@vue-tui/testing";
|
||||
import { Text, useInput, useStdout, type Key } from "@vue-tui/runtime";
|
||||
|
||||
@@ -363,3 +363,18 @@ test("useInput - handle page down", async () => {
|
||||
await stdin.write("\x1b[6~");
|
||||
expect(calls[0]?.key.pageDown).toBe(true);
|
||||
});
|
||||
|
||||
// --- exitOnCtrlC ---
|
||||
|
||||
test("exitOnCtrlC intercepts \\x03 in raw mode", async () => {
|
||||
const handler = vi.fn();
|
||||
const App = defineComponent(() => {
|
||||
useInput(handler);
|
||||
return () => <Text>running</Text>;
|
||||
});
|
||||
const { stdin, waitUntilExit } = await render(App, { exitOnCtrlC: true });
|
||||
await stdin.write("\x03");
|
||||
// Should exit without calling user handler
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
await expect(waitUntilExit()).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user