fix: let xterm.js handle keyboard input natively for scroll-on-input
Only intercept keys when mobile virtual modifier buttons are active. Previously all special keys (Enter, Ctrl+C, arrows) were intercepted and manually re-encoded, bypassing xterm's built-in scrollOnUserInput.
This commit is contained in:
@@ -52,7 +52,7 @@ describe("terminal key helpers", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("intercepts special keys and modifier combos", () => {
|
it("only intercepts when pending modifiers are active", () => {
|
||||||
expect(
|
expect(
|
||||||
shouldInterceptDomTerminalKey({
|
shouldInterceptDomTerminalKey({
|
||||||
key: "Escape",
|
key: "Escape",
|
||||||
@@ -60,7 +60,7 @@ describe("terminal key helpers", () => {
|
|||||||
altKey: false,
|
altKey: false,
|
||||||
pendingModifiers: { ctrl: false, shift: false, alt: false },
|
pendingModifiers: { ctrl: false, shift: false, alt: false },
|
||||||
}),
|
}),
|
||||||
).toBe(true);
|
).toBe(false);
|
||||||
expect(
|
expect(
|
||||||
shouldInterceptDomTerminalKey({
|
shouldInterceptDomTerminalKey({
|
||||||
key: "c",
|
key: "c",
|
||||||
@@ -68,15 +68,23 @@ describe("terminal key helpers", () => {
|
|||||||
altKey: false,
|
altKey: false,
|
||||||
pendingModifiers: { ctrl: false, shift: false, alt: false },
|
pendingModifiers: { ctrl: false, shift: false, alt: false },
|
||||||
}),
|
}),
|
||||||
).toBe(true);
|
).toBe(false);
|
||||||
expect(
|
expect(
|
||||||
shouldInterceptDomTerminalKey({
|
shouldInterceptDomTerminalKey({
|
||||||
key: "c",
|
key: "c",
|
||||||
ctrlKey: false,
|
ctrlKey: false,
|
||||||
altKey: false,
|
altKey: false,
|
||||||
pendingModifiers: { ctrl: false, shift: false, alt: false },
|
pendingModifiers: { ctrl: true, shift: false, alt: false },
|
||||||
}),
|
}),
|
||||||
).toBe(false);
|
).toBe(true);
|
||||||
|
expect(
|
||||||
|
shouldInterceptDomTerminalKey({
|
||||||
|
key: "Escape",
|
||||||
|
ctrlKey: false,
|
||||||
|
altKey: false,
|
||||||
|
pendingModifiers: { ctrl: false, shift: false, alt: true },
|
||||||
|
}),
|
||||||
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("detects pending modifier state", () => {
|
it("detects pending modifier state", () => {
|
||||||
|
|||||||
@@ -88,12 +88,7 @@ export function shouldInterceptDomTerminalKey(args: {
|
|||||||
altKey: boolean;
|
altKey: boolean;
|
||||||
pendingModifiers: PendingTerminalModifiers;
|
pendingModifiers: PendingTerminalModifiers;
|
||||||
}): boolean {
|
}): boolean {
|
||||||
return (
|
return hasPendingTerminalModifiers(args.pendingModifiers);
|
||||||
args.key.length > 1 ||
|
|
||||||
args.ctrlKey ||
|
|
||||||
args.altKey ||
|
|
||||||
hasPendingTerminalModifiers(args.pendingModifiers)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mergeTerminalModifiers(args: {
|
export function mergeTerminalModifiers(args: {
|
||||||
|
|||||||
Reference in New Issue
Block a user