diff --git a/lib/pangea/widgets/igc/pangea_text_controller.dart b/lib/pangea/widgets/igc/pangea_text_controller.dart index adecb4f00..b91186c22 100644 --- a/lib/pangea/widgets/igc/pangea_text_controller.dart +++ b/lib/pangea/widgets/igc/pangea_text_controller.dart @@ -71,6 +71,16 @@ class PangeaTextController extends TextEditingController { choreographer.igc.igcTextData!.getTopMatchIndexForOffset( selection.baseOffset, ); + + // if autoplay on and it start then just start it + if (matchIndex != -1 && + choreographer.itAutoPlayEnabled && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart) { + return choreographer.onITStart( + choreographer.igc.igcTextData!.matches[matchIndex], + ); + } + final Widget? cardToShow = matchIndex != -1 ? SpanCard( scm: SpanCardModel( @@ -82,8 +92,8 @@ class PangeaTextController extends TextEditingController { debugPrint("onSentenceRewrite $tokenIndex $sentenceRewrite"); }), onIgnore: () => choreographer.onIgnoreMatch( - cursorOffset: selection.baseOffset, - ), + cursorOffset: selection.baseOffset, + ), onITStart: () { choreographer.onITStart( choreographer.igc.igcTextData!.matches[matchIndex], @@ -96,24 +106,15 @@ class PangeaTextController extends TextEditingController { : null; if (cardToShow != null) { - if ( - choreographer.itAutoPlayEnabled && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ) { - choreographer.onITStart( - choreographer.igc.igcTextData!.matches[matchIndex], - ); - } else { - OverlayUtil.showPositionedCard( - context: context, - cardSize: matchIndex != -1 && - choreographer.igc.igcTextData!.matches[matchIndex].isITStart - ? const Size(350, 260) - : const Size(350, 400), - cardToShow: cardToShow, - transformTargetId: choreographer.inputTransformTargetKey, - ); - } + OverlayUtil.showPositionedCard( + context: context, + cardSize: matchIndex != -1 && + choreographer.igc.igcTextData!.matches[matchIndex].isITStart + ? const Size(350, 260) + : const Size(350, 400), + cardToShow: cardToShow, + transformTargetId: choreographer.inputTransformTargetKey, + ); } }