Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: swipe typing duplicate word issue fixed (@HemendraSinghShekhawat) #6018

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions frontend/src/ts/controllers/input-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1386,9 +1386,18 @@ $("#wordsInput").on("input", (event) => {
}
}
}
if (inputValue !== currTestInput) {

/* this boolean implies that two input are swipe-typed
consecutively without user inserting space in between */
const doesInputHaveSpaceBetween = inputValue.trim().includes(" ");
if (inputValue !== currTestInput && !doesInputHaveSpaceBetween) {
let diffStart = 0;
while (inputValue[diffStart] === currTestInput[diffStart]) {
// here added undefined check too as the first flag will
// be true even if diffStart overflows the length
while (
inputValue[diffStart] === currTestInput[diffStart] &&
inputValue[diffStart] !== undefined
) {
diffStart++;
}

Expand All @@ -1400,6 +1409,11 @@ $("#wordsInput").on("input", (event) => {
// passing realInput to allow for correct Korean character compilation
handleChar(inputValue[i] as string, i - iOffset, realInputValue);
}
} else {
// simulate space if there is space between input i.e the input is swipe-typed
if (inputValue.trim() !== currTestInput) {
void handleSpace();
}
}

setWordsInput(" " + TestInput.input.current);
Expand Down
Loading