fix: respond to PTY cursor queries

This commit is contained in:
Peter Steinberger
2026-01-17 07:05:15 +00:00
parent a85ddf258c
commit 5dc87a2ed4
4 changed files with 42 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
import { expect, test } from "vitest";
import { buildCursorPositionResponse, stripDsrRequests } from "./pty-dsr.js";
test("stripDsrRequests removes cursor queries and counts them", () => {
const input = "hi\x1b[6nthere\x1b[?6n";
const { cleaned, requests } = stripDsrRequests(input);
expect(cleaned).toBe("hithere");
expect(requests).toBe(2);
});
test("buildCursorPositionResponse returns CPR sequence", () => {
expect(buildCursorPositionResponse()).toBe("\x1b[1;1R");
expect(buildCursorPositionResponse(12, 34)).toBe("\x1b[12;34R");
});