Add ability to limit removal of consecutive duplicate lines to selected text

Fix #8459, close #8535
This commit is contained in:
Scott Sumner 2020-07-07 15:28:26 -04:00 committed by Don HO
parent 8f1b4aa6cc
commit acb4e5ae18
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
1 changed files with 8 additions and 5 deletions

View File

@ -1427,14 +1427,17 @@ void Notepad_plus::removeDuplicateLines()
env._str2Search = TEXT("^(.*(\\r?\\n|\\r))(\\1)+");
env._str4Replace = TEXT("\\1");
env._searchType = FindRegex;
_findReplaceDlg.processAll(ProcessReplaceAll, &env, true);
env._searchType = FindRegex;
auto mainSelStart = _pEditView->execute(SCI_GETSELECTIONSTART);
auto mainSelEnd = _pEditView->execute(SCI_GETSELECTIONEND);
auto mainSelLength = mainSelEnd - mainSelStart;
bool isEntireDoc = mainSelLength == 0;
env._isInSelection = !isEntireDoc;
_findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc);
// remove the last line if it's a duplicate line.
env._str2Search = TEXT("^(.+)(\\r?\\n|\\r)(\\1)$");
env._str4Replace = TEXT("\\1");
env._searchType = FindRegex;
_findReplaceDlg.processAll(ProcessReplaceAll, &env, true);
_findReplaceDlg.processAll(ProcessReplaceAll, &env, isEntireDoc);
}
void Notepad_plus::getMatchedFileNames(const TCHAR *dir, const vector<generic_string> & patterns, vector<generic_string> & fileNames, bool isRecursive, bool isInHiddenDir)