[BUG_FIXED] Fix auto-insert bad behaviour.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@1333 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2015-02-04 01:13:58 +00:00
parent b75fb7cb4a
commit 435b1001b9

View File

@ -446,6 +446,8 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
int posToDetectLine = _pEditView->execute(SCI_LINEFROMPOSITION, posToDetect); int posToDetectLine = _pEditView->execute(SCI_LINEFROMPOSITION, posToDetect);
for (int i = _insertedMatchedChars.size() - 1; i >= 0; --i) for (int i = _insertedMatchedChars.size() - 1; i >= 0; --i)
{
if (_insertedMatchedChars[i]._c == startChar)
{ {
if (_insertedMatchedChars[i]._pos < posToDetect) if (_insertedMatchedChars[i]._pos < posToDetect)
{ {
@ -458,19 +460,22 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
{ {
char aChar = (char)_pEditView->execute(SCI_GETCHARAT, j); char aChar = (char)_pEditView->execute(SCI_GETCHARAT, j);
if (aChar != ' ') // non space is not allowed
{
if (aChar == endChar) // found it!!! if (aChar == endChar) // found it!!!
{ {
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
return j; return j;
} }
else // whichever character, stop searching
if (aChar == startChar) // a new start, stop searching
{ {
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
return -1; return -1;
} }
} }
} }
}
else // not in the same line else // not in the same line
{ {
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
@ -481,6 +486,7 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
} }
} }
}
return -1; return -1;
} }