fix: stabilize pty send-keys tests

This commit is contained in:
Peter Steinberger
2026-01-17 06:32:24 +00:00
parent 5ebfc0738f
commit a4178e4062
3 changed files with 11 additions and 5 deletions

View File

@@ -12,6 +12,10 @@ type Modifiers = {
shift: boolean;
};
function escapeRegExp(value: string) {
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
const namedKeyMap = new Map<string, string>([
["enter", CR],
["return", CR],
@@ -231,8 +235,9 @@ function xtermModifier(mods: Modifiers): number {
}
function applyXtermModifier(sequence: string, modifier: number): string | null {
const csiNumber = /^\x1b\[(\d+)([~A-Z])$/;
const csiArrow = /^\x1b\[(A|B|C|D|H|F)$/;
const escPattern = escapeRegExp(ESC);
const csiNumber = new RegExp(`^${escPattern}\\[(\\d+)([~A-Z])$`);
const csiArrow = new RegExp(`^${escPattern}\\[(A|B|C|D|H|F)$`);
const numberMatch = sequence.match(csiNumber);
if (numberMatch) {