|
|
@ -1493,11 +1493,11 @@ void Notepad_plus::removeEmptyLine(bool isBlankContained)
|
|
|
|
FindOption env;
|
|
|
|
FindOption env;
|
|
|
|
if (isBlankContained)
|
|
|
|
if (isBlankContained)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
env._str2Search = TEXT("^([\\t ]*$(\\r?\\n|\\r))(\\1)*");
|
|
|
|
env._str2Search = TEXT("^(?>[\\t ]*[\\r\\n]+)+");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
env._str2Search = TEXT("^$(\\r?\\n|\\r)(\\1)*");
|
|
|
|
env._str2Search = TEXT("^[\\r\\n]+");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
env._str4Replace = TEXT("");
|
|
|
|
env._str4Replace = TEXT("");
|
|
|
|
env._searchType = FindRegex;
|
|
|
|
env._searchType = FindRegex;
|
|
|
@ -1509,15 +1509,22 @@ void Notepad_plus::removeEmptyLine(bool isBlankContained)
|
|
|
|
_findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc);
|
|
|
|
_findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc);
|
|
|
|
|
|
|
|
|
|
|
|
// remove the last line if it's an empty line.
|
|
|
|
// remove the last line if it's an empty line.
|
|
|
|
if (isBlankContained)
|
|
|
|
auto lastLineDoc = _pEditView->execute(SCI_GETLINECOUNT) - 1;
|
|
|
|
{
|
|
|
|
auto str2Search = isBlankContained ? TEXT("[\\r\\n]+^[\\t ]*$|^[\\t ]+$") : TEXT("[\\r\\n]+^$");
|
|
|
|
env._str2Search = TEXT("(\\r?\\n|\\r)^[\\t ]*$");
|
|
|
|
auto startPos = _pEditView->execute(SCI_POSITIONFROMLINE, lastLineDoc - 1);
|
|
|
|
}
|
|
|
|
auto endPos = _pEditView->execute(SCI_GETLENGTH);
|
|
|
|
else
|
|
|
|
if (!isEntireDoc)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
env._str2Search = TEXT("(\\r?\\n|\\r)^$");
|
|
|
|
startPos = _pEditView->execute(SCI_GETSELECTIONSTART);
|
|
|
|
|
|
|
|
endPos = _pEditView->execute(SCI_GETSELECTIONEND);
|
|
|
|
|
|
|
|
auto endLine = _pEditView->execute(SCI_LINEFROMPOSITION, endPos);
|
|
|
|
|
|
|
|
if (endPos != (_pEditView->execute(SCI_POSITIONFROMLINE, endLine) + _pEditView->execute(SCI_LINELENGTH, endLine)))
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc);
|
|
|
|
_pEditView->execute(SCI_SETSEARCHFLAGS, SCFIND_REGEXP|SCFIND_POSIX);
|
|
|
|
|
|
|
|
auto posFound = _pEditView->searchInTarget(str2Search, lstrlen(str2Search), startPos, endPos);
|
|
|
|
|
|
|
|
if (posFound >= 0)
|
|
|
|
|
|
|
|
_pEditView->replaceTarget(TEXT(""), posFound, endPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Notepad_plus::removeDuplicateLines()
|
|
|
|
void Notepad_plus::removeDuplicateLines()
|
|
|
|