Commit 3b636b58 authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

riched20: EM_GETTEXTLENGTHEX must not count last paragraph break if GTL_USECRLF.

parent b8e10c75
...@@ -59,7 +59,7 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how) ...@@ -59,7 +59,7 @@ int ME_GetTextLengthEx(ME_TextEditor *editor, const GETTEXTLENGTHEX *how)
length = ME_GetTextLength(editor); length = ME_GetTextLength(editor);
if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE) && (how->flags & GTL_USECRLF)) if ((GetWindowLongW(editor->hWnd, GWL_STYLE) & ES_MULTILINE) && (how->flags & GTL_USECRLF))
length += editor->nParagraphs; length += editor->nParagraphs - 1;
if (how->flags & GTL_NUMBYTES) if (how->flags & GTL_NUMBYTES)
{ {
......
...@@ -2504,8 +2504,10 @@ static void test_EM_GETTEXTLENGTHEX(void) ...@@ -2504,8 +2504,10 @@ static void test_EM_GETTEXTLENGTHEX(void)
HWND hwnd; HWND hwnd;
GETTEXTLENGTHEX gtl; GETTEXTLENGTHEX gtl;
int ret; int ret;
const char * base_string = "base string";
const char * test_string = "a\nb\n\n\r\n"; const char * test_string = "a\nb\n\n\r\n";
const char * test_string_after = "a"; const char * test_string_after = "a";
const char * test_string_2 = "a\rtest\rstring";
char buffer[64] = {0}; char buffer[64] = {0};
/* single line */ /* single line */
...@@ -2523,6 +2525,18 @@ static void test_EM_GETTEXTLENGTHEX(void) ...@@ -2523,6 +2525,18 @@ static void test_EM_GETTEXTLENGTHEX(void)
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0); ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
ok(ret == 0, "ret %d\n",ret); 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)&gtl, 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)&gtl, 0);
ok(ret == strlen(base_string), "ret %d\n",ret);
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string); SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string);
gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF;
...@@ -2549,19 +2563,43 @@ static void test_EM_GETTEXTLENGTHEX(void) ...@@ -2549,19 +2563,43 @@ static void test_EM_GETTEXTLENGTHEX(void)
gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF;
gtl.codepage = CP_ACP; gtl.codepage = CP_ACP;
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0); ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
todo_wine ok(ret == 0, "ret %d\n",ret); ok(ret == 0, "ret %d\n",ret);
gtl.flags = GTL_NUMCHARS | GTL_PRECISE; gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
gtl.codepage = CP_ACP; gtl.codepage = CP_ACP;
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0); ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
ok(ret == 0, "ret %d\n",ret); 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)&gtl, 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)&gtl, 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)&gtl, 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)&gtl, 0);
ok(ret == strlen(test_string_2), "ret %d\n",ret);
SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string); SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) test_string);
gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF; gtl.flags = GTL_NUMCHARS | GTL_PRECISE | GTL_USECRLF;
gtl.codepage = CP_ACP; gtl.codepage = CP_ACP;
ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0); ret = SendMessageA(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
todo_wine ok(ret == 10, "ret %d\n",ret); ok(ret == 10, "ret %d\n",ret);
gtl.flags = GTL_NUMCHARS | GTL_PRECISE; gtl.flags = GTL_NUMCHARS | GTL_PRECISE;
gtl.codepage = CP_ACP; gtl.codepage = CP_ACP;
......
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