feat(shortcuts): suppress Shift+Esc browser task manager

This commit is contained in:
lxk955 authored and GitHub committed 2026-10-03 21:57:22 +08:00
1 parent b498b1e63a
commit 37d5ea0bd4
4 files changed
+49 -1

No files matched your search

@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
import {
eventToModifierOnlyShortcut,
eventToShortcut,
isBrowserTaskManagerShortcut,
isConvertNamingStyleShortcut,
isEditTableStructureShortcut,
isExecuteSqlInNewResultTabShortcut,
@@ -264,3 +265,19 @@ describe("tabSwitcherDirectionFromShortcut", () => {
expect(tabSwitcherDirectionFromShortcut({ key: "Tab", ctrlKey: true }, { tabSwitcher: "Shift+Ctrl+Tab" })).toBeNull();
});
});
describe("isBrowserTaskManagerShortcut", () => {
it("matches Shift+Escape combinations and rejects regular Escape or extra modifiers", () => {
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true })).toBe(true);
expect(isBrowserTaskManagerShortcut({ key: "Esc", shiftKey: true })).toBe(true);
expect(isBrowserTaskManagerShortcut({ code: "Escape", shiftKey: true, key: "Unidentified" })).toBe(true);
expect(isBrowserTaskManagerShortcut({ key: "Escape" })).toBe(false);
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: false })).toBe(false);
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, ctrlKey: true })).toBe(false);
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, metaKey: true })).toBe(false);
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, altKey: true })).toBe(false);
expect(isBrowserTaskManagerShortcut({ key: "Escape", shiftKey: true, isComposing: true })).toBe(false);
expect(isBrowserTaskManagerShortcut({ key: "x", shiftKey: true })).toBe(false);
});
});
@@ -383,3 +383,9 @@ export function isBrowserReloadShortcut(event: ShortcutLikeEvent): boolean {
if (key === "F5") return true;
return key === "r" && (!!event.metaKey || !!event.ctrlKey);
}
export function isBrowserTaskManagerShortcut(event: ShortcutLikeEvent): boolean {
if (event.isComposing || event.altKey || event.ctrlKey || event.metaKey) return false;
if (!event.shiftKey) return false;
return event.key === "Escape" || event.key === "Esc" || event.code === "Escape";
}