diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c index 97b5a67..7da521c 100644 --- a/dlls/riched20/string.c +++ b/dlls/riched20/string.c @@ -304,6 +304,8 @@ ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code) /* FIXME: Native also knows about punctuation */ TRACE("s==%s, start==%d, len==%d, code==%d\n", debugstr_wn(s, len), start, len, code); + /* convert number of bytes to number of characters. */ + len /= sizeof(WCHAR); switch (code) { case WB_ISDELIMITER: @@ -330,11 +332,23 @@ ME_WordBreakProc(LPWSTR s, INT start, INT len, INT code) int ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code) { - /* FIXME: ANSIfy the string when bEmulateVersion10 is TRUE */ - if (!editor->pfnWordBreak) - return ME_WordBreakProc(str->szData, start, str->nLen, code); - else - return editor->pfnWordBreak(str->szData, start, str->nLen, code); + if (!editor->pfnWordBreak) { + return ME_WordBreakProc(str->szData, start, str->nLen*sizeof(WCHAR), code); + } else if (!editor->bEmulateVersion10) { + /* MSDN lied about the third parameter for EditWordBreakProc being the number + * of characters, it is actually the number of bytes of the string. */ + return editor->pfnWordBreak(str->szData, start, str->nLen*sizeof(WCHAR), code); + } else { + int result; + int buffer_size = WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen, + NULL, 0, NULL, NULL); + char *buffer = (char*)heap_alloc(buffer_size); + WideCharToMultiByte(CP_ACP, 0, str->szData, str->nLen, + buffer, buffer_size, NULL, NULL); + result = editor->pfnWordBreak(str->szData, start, str->nLen, code); + heap_free(buffer); + return result; + } } LPWSTR ME_ToUnicode(BOOL unicode, LPVOID psz) diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 3a72e30..10de4b5 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -5651,7 +5651,7 @@ static void test_word_movement(void) /* one twoX|three */ SendMessage(hwnd, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); ok(sel_start == sel_end, "Selection should be empty\n"); - todo_wine ok(sel_start == 8, "Cursor is at %d instead of %d\n", sel_start, 8); + ok(sel_start == 8, "Cursor is at %d instead of %d\n", sel_start, 8); DestroyWindow(hwnd); }