From 9d467f59590b92eeca6c844cf44365105a26d882 Mon Sep 17 00:00:00 2001 From: Jack Date: Wed, 7 Jul 2021 00:41:00 +0100 Subject: [PATCH] fixed backspace not working as intended. closes #1598 --- src/js/input-controller.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/js/input-controller.js b/src/js/input-controller.js index 75ad2b3c5..3874c84fb 100644 --- a/src/js/input-controller.js +++ b/src/js/input-controller.js @@ -166,7 +166,7 @@ function handleBackspace(event) { // } if ( - /^[ £§`~!@#$%^&*()_+-=[]{};':"\|,.\/<>\?]*$/g.test( + /^[ £§`~!@#$%^&*()_+-=[\]{};':"|,./<>?]*$/g.test( TestLogic.input.getCurrent() ) ) { @@ -185,20 +185,21 @@ function handleBackspace(event) { TestLogic.input.popHistory(); TestLogic.corrected.popHistory(); } else { - const regex = new RegExp( - /[ £§`~!@#$%^&*()_+-=[]{};':"\|,.\/<>\?]/, - "g" - ); + const regex = new RegExp(/[ £§`~!@#$%^&*()_+-=[\]{};':"|,./<>?]/, "g"); let input = TestLogic.input.getCurrent(); regex.test(input); // let puncIndex = regex.lastIndex; - let puncIndex = input.lastIndexOfRegex(/\W/g); - while (/\W/g.test(input.slice(-1))) { + let puncIndex = input.lastIndexOfRegex( + /[ £§`~!@#$%^&*()_+-=[\]{};':"|,./<>?]/g + ); + while (/[ £§`~!@#$%^&*()_+-=[\]{};':"|,./<>?]/g.test(input.slice(-1))) { input = input.substring(0, input.length - 1); } - puncIndex = input.lastIndexOfRegex(/\W/g); + puncIndex = input.lastIndexOfRegex( + /[ £§`~!@#$%^&*()_+-=[\]{};':"|,./<>?]/g + ); TestLogic.input.setCurrent(input.substring(0, puncIndex + 1)); } } else {