Fix search/replace deleting part of line following the last match on that line. Also a minor optimisation.

Originally committed to SVN as r2280.
This commit is contained in:
Niels Martin Hansen 2008-07-23 16:09:27 +00:00
parent 5d3b1fe8c2
commit 7342c2b617
1 changed files with 3 additions and 2 deletions

View File

@ -481,8 +481,9 @@ void SearchReplaceEngine::ReplaceAll() {
// Normal replace // Normal replace
else { else {
if (!Search.matchCase) { if (!Search.matchCase) {
wxString Left, Right = *Text; wxString Left = _T(""), Right = *Text;
int pos = 0; int pos = 0;
Left.Alloc(Right.Len());
while (pos <= (int)(Right.Len() - LookFor.Len())) { while (pos <= (int)(Right.Len() - LookFor.Len())) {
if (Right.Mid(pos, LookFor.Len()).CmpNoCase(LookFor) == 0) { if (Right.Mid(pos, LookFor.Len()).CmpNoCase(LookFor) == 0) {
Left.Append(Right.Mid(0,pos)).Append(ReplaceWith); Left.Append(Right.Mid(0,pos)).Append(ReplaceWith);
@ -496,7 +497,7 @@ void SearchReplaceEngine::ReplaceAll() {
} }
} }
if (replaced) { if (replaced) {
*Text = Left; *Text = Left + Right;
} }
} }
else { else {