Skip to content

Commit

Permalink
Merge pull request #611 from StarkZhidian/main
Browse files Browse the repository at this point in the history
--bugfix=Fix SymbolPairMatch#matchBestPair return incorrect result
  • Loading branch information
Rosemoe authored Aug 26, 2024
2 parents 4f3e36a + 5606cdb commit 1703c04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ public void commitText(CharSequence text, boolean applyAutoIndent) {
}

pair = languageSymbolPairs.matchBestPair(
this.text, cursor.left(),
this, cursor.left(),
inputText, firstCharFromText
);
}
Expand All @@ -1897,9 +1897,7 @@ public void commitText(CharSequence text, boolean applyAutoIndent) {
var editorText = this.text;
var quoteHandler = editorLanguage.getQuickQuoteHandler();

if (pair != null && pair != SymbolPairMatch.SymbolPair.EMPTY_SYMBOL_PAIR
&& (pair.shouldReplace(this))
) {
if (pair != null && pair != SymbolPairMatch.SymbolPair.EMPTY_SYMBOL_PAIR) {

// QuickQuoteHandler can easily implement the feature of AutoSurround
// and is at a higher level (customizable),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ public final List<SymbolPair> matchBestPairList(char editChar) {
}

@Nullable
public final SymbolPair matchBestPair(Content content, CharPosition cursorPosition, char[] inputCharArray, char firstChar) {
public final SymbolPair matchBestPair(CodeEditor editor, CharPosition cursorPosition, char[] inputCharArray, char firstChar) {
final Content content = editor.getText();
// do not apply single character pairs for text with length > 1
var singleCharPair = inputCharArray == null ? matchBestPairBySingleChar(firstChar) : null;

Expand All @@ -140,6 +141,9 @@ public final SymbolPair matchBestPair(Content content, CharPosition cursorPositi

SymbolPair matchPair = null;
for (var pair : matchList) {
if (!pair.shouldReplace(editor)) {
continue;
}
var openCharArray = pair.open.toCharArray();

// if flag is not 1, no match
Expand Down

0 comments on commit 1703c04

Please sign in to comment.