Squashed 'third_party/pi/' content from commit d981de122
git-subtree-dir: third_party/pi git-subtree-split: d981de1229ef899957bbe968bc8dcda02a21f477
This commit is contained in:
42
packages/coding-agent/test/keybindings.test.ts
Normal file
42
packages/coding-agent/test/keybindings.test.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { KEYBINDINGS, useWindowsKeybindings } from "../src/core/keybindings.ts";
|
||||
|
||||
describe("Windows keybinding defaults", () => {
|
||||
it("uses Windows keybindings on native Windows", () => {
|
||||
expect(useWindowsKeybindings("win32", {})).toBe(true);
|
||||
});
|
||||
|
||||
it("uses Windows keybindings in WSL without relying on Windows Terminal detection", () => {
|
||||
expect(useWindowsKeybindings("linux", { WSL_DISTRO_NAME: "Ubuntu" })).toBe(true);
|
||||
expect(useWindowsKeybindings("linux", { WSL_INTEROP: "/run/WSL/123_interop" })).toBe(true);
|
||||
});
|
||||
|
||||
it("does not use Windows keybindings from WT_SESSION alone", () => {
|
||||
expect(useWindowsKeybindings("linux", { WT_SESSION: "session" })).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps non-Windows defaults on other platforms", () => {
|
||||
expect(useWindowsKeybindings("linux", {})).toBe(false);
|
||||
expect(useWindowsKeybindings("darwin", {})).toBe(false);
|
||||
});
|
||||
|
||||
it("applies the detected defaults consistently", () => {
|
||||
const windowsKeybindings = useWindowsKeybindings();
|
||||
const nativeWindows = process.platform === "win32";
|
||||
|
||||
expect(KEYBINDINGS["app.clipboard.pasteImage"].defaultKeys).toBe(windowsKeybindings ? "alt+v" : "ctrl+v");
|
||||
expect(KEYBINDINGS["tui.altScreen.search"].defaultKeys).toBe(windowsKeybindings ? "ctrl+f" : "ctrl+shift+f");
|
||||
expect(KEYBINDINGS["app.message.followUp"].defaultKeys).toBe(windowsKeybindings ? "ctrl+q" : "alt+enter");
|
||||
expect(KEYBINDINGS["app.model.cycleBackward"].defaultKeys).toBe(windowsKeybindings ? "alt+p" : "shift+ctrl+p");
|
||||
expect(KEYBINDINGS["tui.editor.undo"].defaultKeys).toBe(
|
||||
nativeWindows ? "ctrl+z" : windowsKeybindings ? "alt+z" : "ctrl+-",
|
||||
);
|
||||
expect(KEYBINDINGS["tui.altScreen.previousPrompt"].defaultKeys).toEqual(
|
||||
windowsKeybindings ? "ctrl+up" : ["ctrl+shift+up", "ctrl+up"],
|
||||
);
|
||||
expect(KEYBINDINGS["tui.altScreen.nextPrompt"].defaultKeys).toEqual(
|
||||
windowsKeybindings ? "ctrl+down" : ["ctrl+shift+down", "ctrl+down"],
|
||||
);
|
||||
expect(KEYBINDINGS["app.message.dequeue"].defaultKeys).toBe(windowsKeybindings ? "alt+q" : "alt+up");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user