Skip to content

Commit f0b8636

Browse files
committed
Fix auto pair complete insert position
1 parent 2957aef commit f0b8636

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

codeview/src/main/java/com/amrdeveloper/codeview/CodeView.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,18 +706,12 @@ public void onTextChanged(CharSequence charSequence, int start, int before, int
706706

707707
if (count == 1 && (enableAutoIndentation || enablePairComplete)) {
708708
char currentChar = charSequence.charAt(start);
709-
if (enableAutoIndentation) {
710-
if (indentationStarts.contains(currentChar))
711-
currentIndentation += tabLength;
712-
else if (indentationEnds.contains(currentChar))
713-
currentIndentation -= tabLength;
714-
}
715709

716710
if (enablePairComplete) {
717711
Character pairValue = mPairCompleteMap.get(currentChar);
718712
if (pairValue != null) {
719713
modified = false;
720-
append(pairValue.toString());
714+
getText().insert(getSelectionEnd(), pairValue.toString());
721715
if (enableAutoIndentation) {
722716
if (indentationStarts.contains(pairValue))
723717
currentIndentation += tabLength;
@@ -727,6 +721,14 @@ else if (indentationEnds.contains(pairValue))
727721
modified = true;
728722
}
729723
}
724+
725+
if (enableAutoIndentation) {
726+
if (indentationStarts.contains(currentChar))
727+
currentIndentation += tabLength;
728+
else if (indentationEnds.contains(currentChar))
729+
currentIndentation -= tabLength;
730+
}
731+
730732
}
731733
}
732734

0 commit comments

Comments
 (0)