mirror of
https://github.com/cline/cline.git
synced 2026-10-24 02:02:27 +08:00
fix(desktop): stop the quit shortcut from reaching input handlers
This commit is contained in:
@@ -152,6 +152,23 @@ describe("QuitHoldHandler", () => {
|
||||
expect(vi.getTimerCount()).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps the quit shortcut from reaching input handlers", () => {
|
||||
const input = document.createElement("textarea");
|
||||
container.appendChild(input);
|
||||
const onInputKeyDown = vi.fn();
|
||||
input.addEventListener("keydown", onInputKeyDown);
|
||||
act(() => {
|
||||
input.dispatchEvent(
|
||||
new KeyboardEvent("keydown", {
|
||||
bubbles: true,
|
||||
key: "q",
|
||||
metaKey: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
expect(onInputKeyDown).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not quit when repeats stop before the hold threshold", () => {
|
||||
press();
|
||||
advance(500);
|
||||
|
||||
@@ -109,6 +109,7 @@ export function QuitHoldHandler({
|
||||
if (areShortcutsSuspended()) return stop();
|
||||
if (!matchesAccelerator(event, accelerator)) return;
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
if (holdMs === 0) {
|
||||
if (!event.repeat) quitApp();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user