Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--bugfix=Fix SymbolPairMatch#matchBestPair return incorrect result #611

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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