richedit: Fixed EM_FINDTEXT to pass todo tests.

There was a bug in ME_FindText which would cause the final caracter
offset to be incorrect when a paragraph was crossed while matching
characters.  The problem was the character offset of the wrong
paragraph was used in the calculation of the start offset of the
match.
This commit is contained in:
Dylan Smith 2009-02-02 01:32:36 -05:00 committed by Alexandre Julliard
parent 8662c6fe7b
commit 95d82484e1
2 changed files with 7 additions and 16 deletions

View File

@ -1763,7 +1763,6 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
if (nCurStart + nMatched == ME_StrLen(pCurItem->member.run.strText)) if (nCurStart + nMatched == ME_StrLen(pCurItem->member.run.strText))
{ {
pCurItem = ME_FindItemFwd(pCurItem, diRun); pCurItem = ME_FindItemFwd(pCurItem, diRun);
para = ME_GetParagraph(pCurItem);
nCurStart = -nMatched; nCurStart = -nMatched;
} }
} }
@ -1814,14 +1813,13 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
ME_DisplayItem *pCurItem = item; ME_DisplayItem *pCurItem = item;
int nCurEnd = nEnd; int nCurEnd = nEnd;
int nMatched = 0; int nMatched = 0;
if (nCurEnd - nMatched == 0) if (nCurEnd == 0)
{ {
pCurItem = ME_FindItemBack(pCurItem, diRun); pCurItem = ME_FindItemBack(pCurItem, diRun);
para = ME_GetParagraph(pCurItem);
nCurEnd = ME_StrLen(pCurItem->member.run.strText) + nMatched; nCurEnd = ME_StrLen(pCurItem->member.run.strText) + nMatched;
} }
while (pCurItem && ME_CharCompare(pCurItem->member.run.strText->szData[nCurEnd - nMatched - 1], text[nLen - nMatched - 1], (flags & FR_MATCHCASE))) while (pCurItem && ME_CharCompare(pCurItem->member.run.strText->szData[nCurEnd - nMatched - 1], text[nLen - nMatched - 1], (flags & FR_MATCHCASE)))
{ {
if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar)) if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar))
@ -1853,7 +1851,8 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
break; break;
} }
nStart = para->member.para.nCharOfs + pCurItem->member.run.nCharOfs + nCurEnd - nMatched; nStart = ME_GetParagraph(pCurItem)->member.para.nCharOfs
+ pCurItem->member.run.nCharOfs + nCurEnd - nMatched;
if (chrgText) if (chrgText)
{ {
chrgText->cpMin = nStart; chrgText->cpMin = nStart;
@ -1867,7 +1866,6 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
pCurItem = ME_FindItemBack(pCurItem, diRun); pCurItem = ME_FindItemBack(pCurItem, diRun);
/* Don't care about pCurItem becoming NULL here; it's already taken /* Don't care about pCurItem becoming NULL here; it's already taken
* care of in the exterior loop condition */ * care of in the exterior loop condition */
para = ME_GetParagraph(pCurItem);
nCurEnd = ME_StrLen(pCurItem->member.run.strText) + nMatched; nCurEnd = ME_StrLen(pCurItem->member.run.strText) + nMatched;
} }
} }

View File

@ -672,15 +672,8 @@ static void run_tests_EM_FINDTEXT(HWND hwnd, const char *name, struct find_s *fi
int i; int i;
for (i = 0; i < num_tests; i++) { for (i = 0; i < num_tests; i++) {
if (*name == '3' && i == 0) { check_EM_FINDTEXT(hwnd, name, &find[i], i);
todo_wine { check_EM_FINDTEXTEX(hwnd, name, &find[i], i);
check_EM_FINDTEXT(hwnd, name, &find[i], i);
check_EM_FINDTEXTEX(hwnd, name, &find[i], i);
}
} else {
check_EM_FINDTEXT(hwnd, name, &find[i], i);
check_EM_FINDTEXTEX(hwnd, name, &find[i], i);
}
} }
} }