Fix Shift+Enter in terminal input modes (#999)
* Fix Shift+Enter terminal input modes * Advertise terminal input capabilities
This commit is contained in:
@@ -19,15 +19,36 @@ describe("encodeTerminalKeyInput", () => {
|
||||
expect(encodeTerminalKeyInput({ key: "Backspace" })).toBe("\x7f");
|
||||
});
|
||||
|
||||
it("encodes shift+enter as kitty keyboard protocol CSI u", () => {
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", shift: true })).toBe("\x1b[13;2u");
|
||||
it("keeps modified Enter as carriage return before enhanced input mode is active", () => {
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", shift: true })).toBe("\r");
|
||||
});
|
||||
|
||||
it("encodes enter with modifiers using CSI u", () => {
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", ctrl: true })).toBe("\x1b[13;5u");
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", alt: true })).toBe("\x1b[13;3u");
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", meta: true })).toBe("\x1b[13;9u");
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", shift: true, ctrl: true })).toBe("\x1b[13;6u");
|
||||
it("encodes Enter with modifiers using CSI u after Kitty keyboard mode is active", () => {
|
||||
const options = { inputMode: { kittyKeyboardFlags: 7, win32InputMode: false } };
|
||||
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", shift: true }, options)).toBe("\x1b[13;2u");
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", ctrl: true }, options)).toBe("\x1b[13;5u");
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", alt: true }, options)).toBe("\x1b[13;3u");
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", meta: true }, options)).toBe("\x1b[13;9u");
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", shift: true, ctrl: true }, options)).toBe(
|
||||
"\x1b[13;6u",
|
||||
);
|
||||
});
|
||||
|
||||
it("encodes Shift+Enter using Win32 input mode when ConPTY requests it", () => {
|
||||
const options = { inputMode: { kittyKeyboardFlags: 0, win32InputMode: true } };
|
||||
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", shift: true }, options)).toBe(
|
||||
"\x1b[13;28;13;1;16;1_",
|
||||
);
|
||||
});
|
||||
|
||||
it("prefers Win32 input mode over CSI u when both modes are active", () => {
|
||||
const options = { inputMode: { kittyKeyboardFlags: 7, win32InputMode: true } };
|
||||
|
||||
expect(encodeTerminalKeyInput({ key: "Enter", shift: true }, options)).toBe(
|
||||
"\x1b[13;28;13;1;16;1_",
|
||||
);
|
||||
});
|
||||
|
||||
it("returns empty string for unsupported keys", () => {
|
||||
|
||||
Reference in New Issue
Block a user