From 1929cce416910c9c315d368c655899323b6ddc61 Mon Sep 17 00:00:00 2001 From: Don HO Date: Sun, 15 Dec 2019 03:16:34 +0100 Subject: [PATCH] Fix auto-insert bug Fix #6078, fix #7733, close #7742 --- PowerEditor/src/ScitillaComponent/AutoCompletion.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index 566f8a7d..1b757a15 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -555,6 +555,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m bool isCharPrevBlank = (charPrev == ' ' || charPrev == '\t' || charPrev == '\n' || charPrev == '\r' || charPrev == '\0'); int docLen = _pEditView->getCurrentDocLen(); bool isCharNextBlank = (charNext == ' ' || charNext == '\t' || charNext == '\n' || charNext == '\r' || caretPos == docLen); + bool isCharNextCloseSymbol = (charNext == ')' || charNext == ']' || charNext == '}'); bool isInSandwich = (charPrev == '(' && charNext == ')') || (charPrev == '[' && charNext == ']') || (charPrev == '{' && charNext == '}'); // User defined matched pairs should be checked firstly @@ -582,8 +583,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m case int('('): if (matchedPairConf._doParentheses) { - if (isCharNextBlank || isInSandwich) - + if (isCharNextBlank || isCharNextCloseSymbol) { matchedChars = ")"; _insertedMatchedChars.add(MatchedCharInserted(static_cast(character), caretPos - 1)); @@ -594,7 +594,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m case int('['): if (matchedPairConf._doBrackets) { - if (isCharNextBlank || isInSandwich) + if (isCharNextBlank || isCharNextCloseSymbol) { matchedChars = "]"; _insertedMatchedChars.add(MatchedCharInserted(static_cast(character), caretPos - 1)); @@ -605,7 +605,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m case int('{'): if (matchedPairConf._doCurlyBrackets) { - if (isCharNextBlank || isInSandwich) + if (isCharNextBlank || isCharNextCloseSymbol) { matchedChars = "}"; _insertedMatchedChars.add(MatchedCharInserted(static_cast(character), caretPos - 1));