mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 22:04:55 +02:00
[BUG_FIXED] Fix a crash bug while searching in all opened documents if a document contains long line.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@302 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
1d9f93b2a0
commit
e6247761d0
@ -1150,12 +1150,14 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (op) {
|
switch (op)
|
||||||
case ProcessFindAll: {
|
{
|
||||||
|
case ProcessFindAll:
|
||||||
|
{
|
||||||
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart);
|
int lineNumber = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, targetStart);
|
||||||
int lend = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber);
|
//int lend = (*_ppEditView)->execute(SCI_GETLINEENDPOSITION, lineNumber);
|
||||||
int lstart = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber);
|
//int lstart = (*_ppEditView)->execute(SCI_POSITIONFROMLINE, lineNumber);
|
||||||
int nbChar = lend - lstart;
|
int nbChar = (*_ppEditView)->execute(SCI_LINELENGTH, lineNumber);
|
||||||
bool isRealloc = false;
|
bool isRealloc = false;
|
||||||
|
|
||||||
if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer
|
if (_maxNbCharAllocated < nbChar) //line longer than buffer, resize buffer
|
||||||
@ -1164,15 +1166,13 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons
|
|||||||
_maxNbCharAllocated = nbChar;
|
_maxNbCharAllocated = nbChar;
|
||||||
delete [] _line;
|
delete [] _line;
|
||||||
_line = new char[_maxNbCharAllocated + 3];
|
_line = new char[_maxNbCharAllocated + 3];
|
||||||
if (isUnicode) //if unicode, also resize unicode buffer
|
|
||||||
{
|
// also resize unicode buffer
|
||||||
const int uniCharLen = (_maxNbCharAllocated + 3) * 2 + 1;
|
const int uniCharLen = (_maxNbCharAllocated + 3) * 2 + 1;
|
||||||
delete [] _uniCharLine;
|
delete [] _uniCharLine;
|
||||||
_uniCharLine = new char[uniCharLen];
|
_uniCharLine = new char[uniCharLen];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
(*_ppEditView)->execute(SCI_GETLINE, lineNumber, (LPARAM)_line);
|
(*_ppEditView)->execute(SCI_GETLINE, lineNumber, (LPARAM)_line);
|
||||||
|
|
||||||
_line[nbChar] = 0x0D;
|
_line[nbChar] = 0x0D;
|
||||||
_line[nbChar+1] = 0x0A;
|
_line[nbChar+1] = 0x0A;
|
||||||
_line[nbChar+2] = '\0';
|
_line[nbChar+2] = '\0';
|
||||||
@ -1187,16 +1187,20 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons
|
|||||||
{
|
{
|
||||||
pLine = _line;
|
pLine = _line;
|
||||||
}
|
}
|
||||||
//printStr(isUnicode?"unicode":"no unicode");
|
|
||||||
_pFinder->add(FoundInfo(targetStart, targetEnd, pLine, fileName, _pFinder->_lineCounter), lineNumber + 1);
|
_pFinder->add(FoundInfo(targetStart, targetEnd, pLine, fileName, _pFinder->_lineCounter), lineNumber + 1);
|
||||||
break; }
|
|
||||||
|
|
||||||
case ProcessReplaceAll: {
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case ProcessReplaceAll:
|
||||||
|
{
|
||||||
int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace);
|
int replacedLength = (*_ppEditView)->execute(isRegExp?SCI_REPLACETARGETRE:SCI_REPLACETARGET, (WPARAM)stringSizeReplace, (LPARAM)pTextReplace);
|
||||||
replaceDelta = replacedLength - foundTextLen;
|
replaceDelta = replacedLength - foundTextLen;
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ProcessMarkAll: {
|
case ProcessMarkAll:
|
||||||
|
{
|
||||||
if (_doStyleFoundToken)
|
if (_doStyleFoundToken)
|
||||||
{
|
{
|
||||||
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
|
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
|
||||||
@ -1211,23 +1215,31 @@ int FindReplaceDlg::processRange(ProcessOperation op, const char *txt2find, cons
|
|||||||
if (!(state & (1 << MARK_BOOKMARK)))
|
if (!(state & (1 << MARK_BOOKMARK)))
|
||||||
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
|
(*_ppEditView)->execute(SCI_MARKERADD, lineNumber, MARK_BOOKMARK);
|
||||||
}
|
}
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ProcessMarkAll_2: {
|
case ProcessMarkAll_2:
|
||||||
|
{
|
||||||
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2);
|
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_2);
|
||||||
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen);
|
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen);
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ProcessMarkAll_IncSearch: {
|
case ProcessMarkAll_IncSearch:
|
||||||
|
{
|
||||||
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_INC);
|
(*_ppEditView)->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE_INC);
|
||||||
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen);
|
(*_ppEditView)->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen);
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case ProcessCountAll: {
|
case ProcessCountAll:
|
||||||
|
{
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
break; }
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default:
|
||||||
|
{
|
||||||
delete [] pTextFind;
|
delete [] pTextFind;
|
||||||
delete [] pTextReplace;
|
delete [] pTextReplace;
|
||||||
return nbProcessed;
|
return nbProcessed;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user