richedit: Handle negative position given to EM_POSFROMCHAR.

This commit is contained in:
Dylan Smith 2008-10-28 18:16:23 -04:00 committed by Alexandre Julliard
parent 795c4a77aa
commit 09802e2c76
2 changed files with 5 additions and 0 deletions

View File

@ -3544,6 +3544,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
nCharOfs = lParam;
nLength = ME_GetTextLength(editor);
nCharOfs = min(nCharOfs, nLength);
nCharOfs = max(nCharOfs, 0);
ME_RunOfsFromCharOfs(editor, nCharOfs, &pRun, &nOffset);
assert(pRun->type == diRun);

View File

@ -649,6 +649,10 @@ static void test_EM_POSFROMCHAR(void)
SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)+1);
ok(pt.x == xpos, "pt.x = %d\n", pt.x);
/* Try a negative position. */
SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, -1);
ok(pt.x == 1, "pt.x = %d\n", pt.x);
DestroyWindow(hwndRichEdit);
}