@@ -454,32 +454,32 @@ function isCharCorrect(char: string, charIndex: number): boolean {
454454 return false ;
455455}
456456
457- function handleChar (
457+ async function handleChar (
458458 char : string ,
459459 charIndex : number ,
460460 realInputValue ?: string
461- ) : void {
461+ ) : Promise < void > {
462462 if ( TestUI . resultCalculating || TestUI . resultVisible ) {
463463 return ;
464464 }
465465
466466 if ( char === "…" && TestWords . words . getCurrent ( ) [ charIndex ] !== "…" ) {
467467 for ( let i = 0 ; i < 3 ; i ++ ) {
468- handleChar ( "." , charIndex + i ) ;
468+ await handleChar ( "." , charIndex + i ) ;
469469 }
470470
471471 return ;
472472 }
473473
474474 if ( char === "œ" && TestWords . words . getCurrent ( ) [ charIndex ] !== "œ" ) {
475- handleChar ( "o" , charIndex ) ;
476- handleChar ( "e" , charIndex + 1 ) ;
475+ await handleChar ( "o" , charIndex ) ;
476+ await handleChar ( "e" , charIndex + 1 ) ;
477477 return ;
478478 }
479479
480480 if ( char === "æ" && TestWords . words . getCurrent ( ) [ charIndex ] !== "æ" ) {
481- handleChar ( "a" , charIndex ) ;
482- handleChar ( "e" , charIndex + 1 ) ;
481+ await handleChar ( "a" , charIndex ) ;
482+ await handleChar ( "e" , charIndex + 1 ) ;
483483 return ;
484484 }
485485
@@ -725,7 +725,7 @@ function handleChar(
725725 }
726726
727727 const activeWordTopBeforeJump = activeWord ?. offsetTop ;
728- void TestUI . updateActiveWordLetters ( ) ;
728+ await TestUI . updateActiveWordLetters ( ) ;
729729
730730 const newActiveTop = activeWord ?. offsetTop ;
731731 //stop the word jump by slicing off the last character, update word again
@@ -740,7 +740,7 @@ function handleChar(
740740 if ( ! Config . showAllLines ) void TestUI . lineJump ( activeWordTopBeforeJump ) ;
741741 } else {
742742 TestInput . input . current = TestInput . input . current . slice ( 0 , - 1 ) ;
743- void TestUI . updateActiveWordLetters ( ) ;
743+ await TestUI . updateActiveWordLetters ( ) ;
744744 }
745745 }
746746
@@ -777,7 +777,10 @@ function handleChar(
777777 }
778778}
779779
780- function handleTab ( event : JQuery . KeyDownEvent , popupVisible : boolean ) : void {
780+ async function handleTab (
781+ event : JQuery . KeyDownEvent ,
782+ popupVisible : boolean
783+ ) : Promise < void > {
781784 if ( TestUI . resultCalculating ) {
782785 event . preventDefault ( ) ;
783786 return ;
@@ -805,7 +808,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
805808 event . preventDefault ( ) ;
806809 // insert tab character if needed (only during the test)
807810 if ( ! TestUI . resultVisible && shouldInsertTabCharacter ) {
808- handleChar ( "\t" , TestInput . input . current . length ) ;
811+ await handleChar ( "\t" , TestInput . input . current . length ) ;
809812 setWordsInput ( " " + TestInput . input . current ) ;
810813 return ;
811814 }
@@ -832,7 +835,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
832835 // insert tab character if needed (only during the test)
833836 if ( ! TestUI . resultVisible && shouldInsertTabCharacter ) {
834837 event . preventDefault ( ) ;
835- handleChar ( "\t" , TestInput . input . current . length ) ;
838+ await handleChar ( "\t" , TestInput . input . current . length ) ;
836839 setWordsInput ( " " + TestInput . input . current ) ;
837840 return ;
838841 }
@@ -851,7 +854,7 @@ function handleTab(event: JQuery.KeyDownEvent, popupVisible: boolean): void {
851854 // insert tab character if needed
852855 if ( shouldInsertTabCharacter ) {
853856 event . preventDefault ( ) ;
854- handleChar ( "\t" , TestInput . input . current . length ) ;
857+ await handleChar ( "\t" , TestInput . input . current . length ) ;
855858 setWordsInput ( " " + TestInput . input . current ) ;
856859 return ;
857860 }
@@ -934,7 +937,7 @@ $(document).on("keydown", async (event) => {
934937
935938 //tab
936939 if ( event . key === "Tab" ) {
937- handleTab ( event , popupVisible ) ;
940+ await handleTab ( event , popupVisible ) ;
938941 }
939942
940943 //esc
@@ -1103,7 +1106,7 @@ $(document).on("keydown", async (event) => {
11031106 }
11041107 }
11051108 } else {
1106- handleChar ( "\n" , TestInput . input . current . length ) ;
1109+ await handleChar ( "\n" , TestInput . input . current . length ) ;
11071110 setWordsInput ( " " + TestInput . input . current ) ;
11081111 updateUI ( ) ;
11091112 }
@@ -1169,7 +1172,7 @@ $(document).on("keydown", async (event) => {
11691172 )
11701173 ) {
11711174 event . preventDefault ( ) ;
1172- handleChar ( event . key , TestInput . input . current . length ) ;
1175+ await handleChar ( event . key , TestInput . input . current . length ) ;
11731176 updateUI ( ) ;
11741177 setWordsInput ( " " + TestInput . input . current ) ;
11751178 }
@@ -1185,7 +1188,7 @@ $(document).on("keydown", async (event) => {
11851188 const char : string | null = await LayoutEmulator . getCharFromEvent ( event ) ;
11861189 if ( char !== null ) {
11871190 event . preventDefault ( ) ;
1188- handleChar ( char , TestInput . input . current . length ) ;
1191+ await handleChar ( char , TestInput . input . current . length ) ;
11891192 updateUI ( ) ;
11901193 setWordsInput ( " " + TestInput . input . current ) ;
11911194 }
@@ -1273,7 +1276,7 @@ $("#wordsInput").on("beforeinput", (event) => {
12731276 }
12741277} ) ;
12751278
1276- $ ( "#wordsInput" ) . on ( "input" , ( event ) => {
1279+ $ ( "#wordsInput" ) . on ( "input" , async ( event ) => {
12771280 if ( ! event . originalEvent ?. isTrusted || TestUI . testRestarting ) {
12781281 ( event . target as HTMLInputElement ) . value = " " ;
12791282 return ;
@@ -1363,7 +1366,11 @@ $("#wordsInput").on("input", (event) => {
13631366 iOffset = inputValue . indexOf ( " " ) + 1 ;
13641367 }
13651368 for ( let i = diffStart ; i < inputValue . length ; i ++ ) {
1366- handleChar ( inputValue [ i ] as string , i - iOffset , realInputValue ) ;
1369+ await handleChar (
1370+ inputValue [ i ] as string ,
1371+ i - iOffset ,
1372+ realInputValue
1373+ ) ;
13671374 }
13681375 }
13691376 } else if ( containsKorean ) {
@@ -1400,7 +1407,7 @@ $("#wordsInput").on("input", (event) => {
14001407 }
14011408 for ( let i = diffStart ; i < inputValue . length ; i ++ ) {
14021409 // passing realInput to allow for correct Korean character compilation
1403- handleChar ( inputValue [ i ] as string , i - iOffset , realInputValue ) ;
1410+ await handleChar ( inputValue [ i ] as string , i - iOffset , realInputValue ) ;
14041411 }
14051412 }
14061413
0 commit comments