@@ -1769,14 +1769,14 @@ public void indentLines(boolean onlyIfSelected) {
17691769 final var requiredSpaces = tabWidth - (spaces % tabWidth );
17701770 if (spaceCount > 0 && tabCount > 0 ) {
17711771 // indentation contains spaces as well as tabs
1772- // replace the leading indentation with appropriate indendation (according to language.useTabs())
1772+ // replace the leading indentation with appropriate indentation (according to language.useTabs())
17731773 // this should be done while incrementing the indentation
17741774 final var finalSpaceCount = ((requiredSpaces == 0 ? tabWidth : requiredSpaces ) + spaces ) / tabWidth ;
17751775 text .replace (i , 0 , i , endColumn , StringsKt .repeat (tabString , finalSpaceCount ));
17761776 continue ;
17771777 }
17781778
1779- if (requiredSpaces == 0 ) {
1779+ if (requiredSpaces == tabWidth ) {
17801780 // line is evenly indented
17811781 // increase the indentation by \t or tabWidthSpaces
17821782 text .insert (i , endColumn , tabString );
@@ -1818,7 +1818,7 @@ public void unindentSelection() {
18181818 final var extraSpaces = spaces % tabWidth ;
18191819 if (spaceCount > 0 && tabCount > 0 ) {
18201820 // indentation contains spaces as well as tabs
1821- // replace the leading indentation with appropriate indendation (according to language.useTabs())
1821+ // replace the leading indentation with appropriate indentation (according to language.useTabs())
18221822 // this should be done while decrementing the indentation
18231823 final var finalSpaceCount = Math .abs (spaces - (extraSpaces == 0 ? tabWidth : extraSpaces )) / tabWidth ;
18241824 text .replace (i , 0 , i , endColumn , StringsKt .repeat (tabString , finalSpaceCount ));
@@ -1846,6 +1846,10 @@ public void unindentSelection() {
18461846 */
18471847 protected void commitTab () {
18481848 if (inputConnection != null && isEditable ()) {
1849+ if (inputConnection .composingText .isComposing ()) {
1850+ // This external change will damage the composing text (#784)
1851+ restartInput ();
1852+ }
18491853 inputConnection .commitTextInternal (createTabString (), true );
18501854 }
18511855 }
@@ -1913,6 +1917,11 @@ public float updateCursorAnchor() {
19131917 matrix .postTranslate (b [0 ], b [1 ]);
19141918 builder .setMatrix (matrix );
19151919 builder .setSelectionRange (cursor .getLeft (), cursor .getRight ());
1920+
1921+ var composingText = inputConnection .composingText ;
1922+ if (composingText .isComposing ()) {
1923+ builder .setComposingText (composingText .startIndex , text .substring (composingText .startIndex , composingText .endIndex ));
1924+ }
19161925 builder .setInsertionMarkerLocation (x , getRowTop (l ) - getOffsetY (), getRowBaseline (l ) - getOffsetY (), getRowBottom (l ) - getOffsetY (), visible ? CursorAnchorInfo .FLAG_HAS_VISIBLE_REGION : CursorAnchorInfo .FLAG_HAS_INVISIBLE_REGION );
19171926 inputMethodManager .updateCursorAnchorInfo (this , builder .build ());
19181927 }
0 commit comments