@@ -438,10 +438,7 @@ function updateWordWrapperClasses(): void {
438438
439439 updateWordsWidth ( ) ;
440440 updateWordsWrapperHeight ( true ) ;
441- updateWordsMargin ( ) ;
442- setTimeout ( ( ) => {
443- void updateWordsInputPosition ( true ) ;
444- } , 250 ) ;
441+ updateWordsMargin ( updateWordsInputPosition , [ true ] ) ;
445442}
446443
447444export function showWords ( ) : void {
@@ -637,9 +634,16 @@ export function updateWordsWrapperHeight(force = false): void {
637634 outOfFocusEl . style . maxHeight = wordHeight * 3 + "px" ;
638635}
639636
640- function updateWordsMargin ( ) : void {
637+ function updateWordsMargin < T extends unknown [ ] > (
638+ afterCompleteFn : ( ...args : T ) => void ,
639+ args : T
640+ ) : void {
641+ const afterComplete = ( ) : void => {
642+ afterCompleteFn ( ...args ) ;
643+ void updateHintsPositionDebounced ( ) ;
644+ } ;
641645 if ( Config . tapeMode !== "off" ) {
642- void scrollTape ( true , updateHintsPositionDebounced ) ;
646+ void scrollTape ( true , afterComplete ) ;
643647 } else {
644648 const wordsEl = document . getElementById ( "words" ) as HTMLElement ;
645649 const afterNewlineEls =
@@ -653,7 +657,7 @@ function updateWordsMargin(): void {
653657 {
654658 duration : SlowTimer . get ( ) ? 0 : 125 ,
655659 queue : "leftMargin" ,
656- complete : updateHintsPositionDebounced ,
660+ complete : afterComplete ,
657661 }
658662 ) ;
659663 jqWords . dequeue ( "leftMargin" ) ;
@@ -665,7 +669,7 @@ function updateWordsMargin(): void {
665669 for ( const afterNewline of afterNewlineEls ) {
666670 afterNewline . style . marginLeft = `0` ;
667671 }
668- void updateHintsPositionDebounced ( ) ;
672+ afterComplete ( ) ;
669673 }
670674 }
671675}
0 commit comments