Commit 95d82484 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

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.
parent 8662c6fe
......@@ -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;
}
}
......@@ -1815,10 +1814,9 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
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;
}
......@@ -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;
}
}
......
......@@ -672,16 +672,9 @@ 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);
}
}
}
static void test_EM_FINDTEXT(void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment