Module: wine Branch: master Commit: 95d82484e19ce2da3928798bc29216d3f3856e3c URL: http://source.winehq.org/git/wine.git/?a=commit;h=95d82484e19ce2da3928798bc2...
Author: Dylan Smith dylan.ah.smith@gmail.com Date: Mon Feb 2 01:32:36 2009 -0500
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.
---
dlls/riched20/editor.c | 12 +++++------- dlls/riched32/tests/editor.c | 11 ++--------- 2 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 352b827..ca1eb97 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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)) { pCurItem = ME_FindItemFwd(pCurItem, diRun); - para = ME_GetParagraph(pCurItem); nCurStart = -nMatched; } } @@ -1814,14 +1813,13 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH ME_DisplayItem *pCurItem = item; int nCurEnd = nEnd; int nMatched = 0; - - if (nCurEnd - nMatched == 0) + + if (nCurEnd == 0) { pCurItem = ME_FindItemBack(pCurItem, diRun); - para = ME_GetParagraph(pCurItem); 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))) { if ((flags & FR_WHOLEWORD) && isalnumW(wLastChar)) @@ -1853,7 +1851,8 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH 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) { chrgText->cpMin = nStart; @@ -1867,7 +1866,6 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH pCurItem = ME_FindItemBack(pCurItem, diRun); /* Don't care about pCurItem becoming NULL here; it's already taken * care of in the exterior loop condition */ - para = ME_GetParagraph(pCurItem); nCurEnd = ME_StrLen(pCurItem->member.run.strText) + nMatched; } } diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c index e81f033..006da7d 100644 --- a/dlls/riched32/tests/editor.c +++ b/dlls/riched32/tests/editor.c @@ -672,15 +672,8 @@ static void run_tests_EM_FINDTEXT(HWND hwnd, const char *name, struct find_s *fi int i;
for (i = 0; i < num_tests; i++) { - if (*name == '3' && i == 0) { - todo_wine { - 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); - } + check_EM_FINDTEXT(hwnd, name, &find[i], i); + check_EM_FINDTEXTEX(hwnd, name, &find[i], i); } }