[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
This commit is contained in:
Don Ho 2014-12-19 18:40:47 +00:00
parent 6594f4801b
commit 611736b95d

View File

@ -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)
{