From 3b636b58ba6917ca3f1358f4bc363fdd8df6c94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Villac=C3=ADs=20Lasso?= Date: Thu, 6 Dec 2007 13:41:28 -0500 Subject: [PATCH] riched20: EM_GETTEXTLENGTHEX must not count last paragraph break if GTL_USECRLF. --- dlls/riched20/caret.c | 2 +- dlls/riched20/tests/editor.c | 42 ++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index 3bc5b5e4f1..af52e9fce1 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -59,7 +59,7 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) length = ME_GetTextLength(editor); if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE) && (how->flags & GTL_USECRLF)) - length += editor->nParagraphs; + length += editor->nParagraphs - 1; if (how->flags & GTL_NUMBYTES) { diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 83fe42d00f..5512017d0b 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -2504,8 +2504,10 @@ static void test_EM_GETTEXTLENGTHEX(void) HWND hwnd; GETTEXTLENGTHEX gtl; int ret; + const char * base_string = "base string"; const char * test_string = "a\nb\n\n\r\n"; const char * test_string_after = "a"; + const char * test_string_2 = "a\rtest\rstring"; char buffer[64] = {0}; /* single line */ @@ -2523,6 +2525,18 @@ static void test_EM_GETTEXTLENGTHEX(void) ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); ok(ret == 0, "ret %d\n",ret); + SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) base_string); + + gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; + gtl.codepage = CP_ACP; + ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + ok(ret == strlen(base_string), "ret %d\n",ret); + + gtl.flags = GTL_NUMCHARS | GTL_PRECISE; + gtl.codepage = CP_ACP; + ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + ok(ret == strlen(base_string), "ret %d\n",ret); + SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string); gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; @@ -2549,19 +2563,43 @@ static void test_EM_GETTEXTLENGTHEX(void) gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; gtl.codepage = CP_ACP; ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); - todo_wine ok(ret == 0, "ret %d\n",ret); + ok(ret == 0, "ret %d\n",ret); gtl.flags = GTL_NUMCHARS | GTL_PRECISE; gtl.codepage = CP_ACP; ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); ok(ret == 0, "ret %d\n",ret); + SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) base_string); + + gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; + gtl.codepage = CP_ACP; + ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + ok(ret == strlen(base_string), "ret %d\n",ret); + + gtl.flags = GTL_NUMCHARS | GTL_PRECISE; + gtl.codepage = CP_ACP; + ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + ok(ret == strlen(base_string), "ret %d\n",ret); + + SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string_2); + + gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; + gtl.codepage = CP_ACP; + ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + ok(ret == strlen(test_string_2) + 2, "ret %d\n",ret); + + gtl.flags = GTL_NUMCHARS | GTL_PRECISE; + gtl.codepage = CP_ACP; + ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); + ok(ret == strlen(test_string_2), "ret %d\n",ret); + SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string); gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; gtl.codepage = CP_ACP; ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)>l, 0); - todo_wine ok(ret == 10, "ret %d\n",ret); + ok(ret == 10, "ret %d\n",ret); gtl.flags = GTL_NUMCHARS | GTL_PRECISE; gtl.codepage = CP_ACP;