From 611736b95d283c4d7267f56f34ecd800d64fe17c Mon Sep 17 00:00:00 2001 From: Don Ho Date: Fri, 19 Dec 2014 18:40:47 +0000 Subject: [PATCH] [NEW_FEATURE] auto-insert skipping character feature works for "" and '' now. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1311 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../src/ScitillaComponent/AutoCompletion.cpp | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp index df3d2b31..2dc08164 100644 --- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp +++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp @@ -449,7 +449,6 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect) { if (_insertedMatchedChars[i]._pos < posToDetect) { - int startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos); if (posToDetectLine == startPosLine) { @@ -458,16 +457,18 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect) for (int j = posToDetect; j <= endPos; ++j) { char aChar = (char)_pEditView->execute(SCI_GETCHARAT, j); - if (aChar == startChar) - { - _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); - return -1; - } + if (aChar == endChar) // found it!!! { _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); return j; } + + if (aChar == startChar) // a new start, stop searching + { + _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); + return -1; + } } } else // not in the same line @@ -534,12 +535,40 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m case int('"'): if (matchedPairConf._doDoubleQuotes) + { + if (!_insertedMatchedChars.isEmpty()) + { + int pos = _insertedMatchedChars.search('"', char(character), caretPos); + if (pos != -1) + { + _pEditView->execute(SCI_DELETERANGE, pos, 1); + _pEditView->execute(SCI_GOTOPOS, pos); + return; + } + } + matchedChars = "\""; + _insertedMatchedChars.add(MatchedCharInserted(char(character), caretPos - 1)); + } break; case int('\''): if (matchedPairConf._doQuotes) + { + if (!_insertedMatchedChars.isEmpty()) + { + int pos = _insertedMatchedChars.search('\'', char(character), caretPos); + if (pos != -1) + { + _pEditView->execute(SCI_DELETERANGE, pos, 1); + _pEditView->execute(SCI_GOTOPOS, pos); + return; + } + } matchedChars = "'"; + _insertedMatchedChars.add(MatchedCharInserted(char(character), caretPos - 1)); + } break; + case int('>'): { if (matchedPairConf._doHtmlXmlTag && (_curLang == L_HTML || _curLang == L_XML)) @@ -575,6 +604,7 @@ void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & m return; startChar = '{'; } + int pos = _insertedMatchedChars.search(startChar, char(character), caretPos); if (pos != -1) {