Skip to content

Commit

Permalink
fix(editor): symbol completion is conflict with search replace (fix #638
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Rosemoe committed Jan 30, 2025
1 parent 447750f commit d7d4003
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions editor/src/main/java/io/github/rosemoe/sora/widget/CodeEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -1874,16 +1874,28 @@ public void commitText(CharSequence text) {
/**
* Commit text at current state from IME
*
* @param text Text commit by InputConnection
* @param text Text commit by InputConnection
* @param applyAutoIndent Apply automatic indentation
*/
public void commitText(CharSequence text, boolean applyAutoIndent) {
commitText(text, true, true);
}

/**
* Commit text with given options
*
* @param text Text commit by InputConnection
* @param applyAutoIndent Apply automatic indentation
* @param applySymbolCompletion Apply symbol surroundings and completions
*/
public void commitText(CharSequence text, boolean applyAutoIndent, boolean applySymbolCompletion) {
if (text.length() == 0) {
return;
}

// replace text
SymbolPairMatch.SymbolPair pair = null;
if (getProps().symbolPairAutoCompletion && text.length() > 0) {
if (applySymbolCompletion && getProps().symbolPairAutoCompletion && text.length() > 0) {
var endCharFromText = text.charAt(text.length() - 1);

char[] inputText = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public void replaceCurrentMatch(@NonNull String replacement) {
if (replacement.isEmpty()) {
editor.deleteText();
} else {
editor.commitText(replacement);
editor.commitText(replacement, false, false);
}
} else {
gotoNext();
Expand Down

0 comments on commit d7d4003

Please sign in to comment.