Improve the performance of Remove Empty Lines command

Fix #12462, close #12512
This commit is contained in:
Arkadiusz Michalski 2022-11-14 07:14:00 +01:00 committed by Don Ho
parent 87a53d1ed2
commit d53ed27bb3
1 changed files with 4 additions and 4 deletions

View File

@ -1461,11 +1461,11 @@ void Notepad_plus::removeEmptyLine(bool isBlankContained)
FindOption env; FindOption env;
if (isBlankContained) if (isBlankContained)
{ {
env._str2Search = TEXT("^[\\t ]*$(\\r\\n|\\r|\\n)"); env._str2Search = TEXT("^([\\t ]*$(\\r?\\n|\\r))(\\1)*");
} }
else else
{ {
env._str2Search = TEXT("^$(\\r\\n|\\r|\\n)"); env._str2Search = TEXT("^$(\\r?\\n|\\r)(\\1)*");
} }
env._str4Replace = TEXT(""); env._str4Replace = TEXT("");
env._searchType = FindRegex; env._searchType = FindRegex;
@ -1479,11 +1479,11 @@ void Notepad_plus::removeEmptyLine(bool isBlankContained)
// remove the last line if it's an empty line. // remove the last line if it's an empty line.
if (isBlankContained) if (isBlankContained)
{ {
env._str2Search = TEXT("(\\r\\n|\\r|\\n)^[\\t ]*$"); env._str2Search = TEXT("(\\r?\\n|\\r)^[\\t ]*$");
} }
else else
{ {
env._str2Search = TEXT("(\\r\\n|\\r|\\n)^$"); env._str2Search = TEXT("(\\r?\\n|\\r)^$");
} }
_findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc); _findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc);
} }