[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

@ -447,39 +447,45 @@ int InsertedMatchedChars::search(char startChar, char endChar, int posToDetect)
for (int i = _insertedMatchedChars.size() - 1; i >= 0; --i) for (int i = _insertedMatchedChars.size() - 1; i >= 0; --i)
{ {
if (_insertedMatchedChars[i]._pos < posToDetect) if (_insertedMatchedChars[i]._c == startChar)
{ {
int startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos); if (_insertedMatchedChars[i]._pos < posToDetect)
if (posToDetectLine == startPosLine)
{ {
int endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, startPosLine); int startPosLine = _pEditView->execute(SCI_LINEFROMPOSITION, _insertedMatchedChars[i]._pos);
if (posToDetectLine == startPosLine)
for (int j = posToDetect; j <= endPos; ++j)
{ {
char aChar = (char)_pEditView->execute(SCI_GETCHARAT, j); int endPos = _pEditView->execute(SCI_GETLINEENDPOSITION, startPosLine);
if (aChar == endChar) // found it!!! for (int j = posToDetect; j <= endPos; ++j)
{ {
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); char aChar = (char)_pEditView->execute(SCI_GETCHARAT, j);
return j;
}
if (aChar == startChar) // a new start, stop searching if (aChar != ' ') // non space is not allowed
{ {
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
return -1; if (aChar == endChar) // found it!!!
{
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
return j;
}
else // whichever character, stop searching
{
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
return -1;
}
}
} }
} }
else // not in the same line
{
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
}
} }
else // not in the same line else // current position is before matchedStartSybol Pos
{ {
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i); _insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
} }
} }
else // current position is before matchedStartSybol Pos
{
_insertedMatchedChars.erase(_insertedMatchedChars.begin() + i);
}
} }
return -1; return -1;
} }