From 8beddebbd485a5eb2d7b7ebdbef619333bd39d80 Mon Sep 17 00:00:00 2001 From: Miodec Date: Wed, 3 Jul 2024 13:02:57 +0200 Subject: [PATCH] fix: active word duplication in code quotes closes #5505 --- .../src/ts/controllers/input-controller.ts | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/frontend/src/ts/controllers/input-controller.ts b/frontend/src/ts/controllers/input-controller.ts index 7ed39bf96..091544f56 100644 --- a/frontend/src/ts/controllers/input-controller.ts +++ b/frontend/src/ts/controllers/input-controller.ts @@ -768,15 +768,20 @@ function handleChar( const doesCurrentWordHaveTab = /^\t+/.test(TestWords.words.getCurrent()); const isCurrentCharTab = currentWord[TestInput.input.current.length] === "\t"; - if ( - thisCharCorrect && - Config.language.startsWith("code") && - doesCurrentWordHaveTab && - isCurrentCharTab - ) { - const tabEvent = new KeyboardEvent("keydown", { key: "Tab", code: "Tab" }); - document.dispatchEvent(tabEvent); - } + setTimeout(() => { + if ( + thisCharCorrect && + Config.language.startsWith("code") && + doesCurrentWordHaveTab && + isCurrentCharTab + ) { + const tabEvent = new KeyboardEvent("keydown", { + key: "Tab", + code: "Tab", + }); + document.dispatchEvent(tabEvent); + } + }, 0); if (char !== "\n") { void Caret.updatePosition();