Skip to content

Commit de19ff9

Browse files
authored
fix: hotkey issues (@Miodec) (#7802)
1 parent 4ec8aea commit de19ff9

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

frontend/src/ts/input/hotkeys/quickrestart.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getActivePage } from "../../states/core";
66
import { hotkeys, quickRestartHotkeyMap } from "../../states/hotkeys";
77
import { createHotkey } from "./utils";
88
import { getConfig } from "../../config/store";
9-
import { isLongTest } from "../../states/test";
9+
import { isLongTest, wordsHaveNewline, wordsHaveTab } from "../../states/test";
1010

1111
function quickRestart(e: KeyboardEvent): void {
1212
if (isAnyPopupVisible()) {
@@ -37,5 +37,10 @@ createHotkey(
3737
createHotkey(
3838
() => quickRestartHotkeyMap[getConfig.quickRestart],
3939
quickRestart,
40-
() => ({ enabled: isLongTest() }),
40+
() => ({
41+
enabled:
42+
isLongTest() &&
43+
!(wordsHaveTab() && getConfig.quickRestart === "tab") &&
44+
!(wordsHaveNewline() && getConfig.quickRestart === "enter"),
45+
}),
4146
);

frontend/src/ts/states/hotkeys.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,26 @@ createEffect(() => {
2828

2929
function updateHotkeys(): Hotkeys {
3030
const isOnTestPage = getActivePage() === "test";
31+
32+
const quickRestartIsTab = getConfig.quickRestart === "tab";
33+
const quickRestartIsEnter = getConfig.quickRestart === "enter";
34+
// const quickRestartIsEsc = getConfig.quickRestart === "esc";
35+
36+
const commandlineIsTab = getConfig.quickRestart === "esc";
37+
// const commandlineIsEsc = getConfig.quickRestart !== "esc";
38+
3139
return {
3240
quickRestart: shiftHotkey(
3341
quickRestartHotkeyMap[getConfig.quickRestart],
34-
isOnTestPage && (wordsHaveTab() || isLongTest()),
42+
isOnTestPage &&
43+
((wordsHaveTab() && quickRestartIsTab) ||
44+
((wordsHaveNewline() || getConfig.funbox.includes("58008")) &&
45+
quickRestartIsEnter) ||
46+
isLongTest()),
3547
),
3648
commandline: shiftHotkey(
37-
getConfig.quickRestart === "esc" ? "Tab" : "Escape",
38-
isOnTestPage && wordsHaveNewline(),
49+
commandlineIsTab ? "Tab" : "Escape",
50+
isOnTestPage && wordsHaveTab() && commandlineIsTab,
3951
),
4052
};
4153
}

0 commit comments

Comments
 (0)