diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 792f05f..144f794 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -3491,18 +3491,15 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, if (wParam >= 0x40000) nCharOfs = lParam; nLength = ME_GetTextLength(editor); - - if (nCharOfs < nLength) { - ME_RunOfsFromCharOfs(editor, nCharOfs, &pRun, &nOffset); - assert(pRun->type == diRun); - pt.y = pRun->member.run.pt.y; - pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset); - pt.y += ME_GetParagraph(pRun)->member.para.pt.y; - } else { - pt.x = 0; - pt.y = editor->pBuffer->pLast->member.para.pt.y; - } + nCharOfs = min(nCharOfs, nLength); + + ME_RunOfsFromCharOfs(editor, nCharOfs, &pRun, &nOffset); + assert(pRun->type == diRun); + pt.y = pRun->member.run.pt.y; + pt.x = pRun->member.run.pt.x + ME_PointFromChar(editor, &pRun->member.run, nOffset); + pt.y += ME_GetParagraph(pRun)->member.para.pt.y; pt.x += editor->selofs; + pt.x++; /* for some reason native offsets x by one */ si.cbSize = sizeof(si); si.fMask = SIF_POS; diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 5f94e8f..631623d 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -539,9 +539,7 @@ static void test_EM_POSFROMCHAR(void) if (i == 0) { ok(HIWORD(result) == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", HIWORD(result)); - todo_wine { ok(LOWORD(result) == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result)); - } xpos = LOWORD(result); } else if (i == 1) @@ -595,9 +593,7 @@ static void test_EM_POSFROMCHAR(void) result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, 0, 0); ok(HIWORD(result) == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", HIWORD(result)); - todo_wine { ok(LOWORD(result) == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", LOWORD(result)); - } xpos = LOWORD(result); SendMessage(hwndRichEdit, WM_HSCROLL, SB_LINERIGHT, 0); @@ -619,7 +615,7 @@ static void test_EM_POSFROMCHAR(void) xpos = pt.x; SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)); - todo_wine ok(pt.x > xpos, "pt.x = %d\n", pt.x); + ok(pt.x > xpos, "pt.x = %d\n", pt.x); xpos = pt.x; SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pt, SendMessage(hwndRichEdit, WM_GETTEXTLENGTH, 0, 0)+1);