requiring shift + enter to be double tapped to bail out of a test

closes #4149
This commit is contained in:
Miodec 2023-04-11 23:47:41 +02:00
parent f29db00949
commit d7bf0552de

View file

@ -761,6 +761,8 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
}
}
let lastBailoutAttempt = -1;
$(document).keydown(async (event) => {
if (ActivePage.get() == "loading") return;
@ -874,8 +876,23 @@ $(document).keydown(async (event) => {
CustomTextState.isCustomTextLong() ?? false
)
) {
TestInput.setBailout(true);
TestLogic.finish();
const delay = Date.now() - lastBailoutAttempt;
if (lastBailoutAttempt === -1 || delay > 200) {
lastBailoutAttempt = Date.now();
if (delay >= 5000) {
Notifications.add(
"Please double tap shift+enter to confirm bail out",
0,
{
important: true,
duration: 5000,
}
);
}
} else {
TestInput.setBailout(true);
TestLogic.finish();
}
}
} else {
handleChar("\n", TestInput.input.current.length);