riched20: EM_GETTEXTEX with GT_USECRLF should not leave a single CR when running out of space.

This commit is contained in:
Alex Villacís Lasso 2007-12-06 10:47:59 -05:00 committed by Alexandre Julliard
parent 7092590c90
commit 4545f1944e
2 changed files with 31 additions and 1 deletions

View File

@ -2804,7 +2804,10 @@ int ME_GetTextW(ME_TextEditor *editor, WCHAR *buffer, int nStart, int nChars, in
if (!ME_FindItemFwd(item, diRun))
/* No '\r' is appended to the last paragraph. */
nLen = 0;
else {
else if (bCRLF && nChars == 1) {
nLen = 0;
nChars = 0;
} else {
*buffer = '\r';
if (bCRLF)
{

View File

@ -1116,6 +1116,33 @@ static void test_EM_SETTEXTEX(void)
ok(strcmp((const char *)buf, TestItem2_after) == 0,
"WM_GETTEXT did *not* see \\r converted to \\r\\n pairs.\n");
/* Baseline test for just-enough buffer space for string */
getText.cb = (lstrlenW(TestItem2) + 1) * sizeof(WCHAR);
getText.codepage = 1200; /* no constant for unicode */
getText.flags = GT_DEFAULT;
getText.lpDefaultChar = NULL;
getText.lpUsedDefaultChar = NULL;
memset(buf, 0, MAX_BUF_LEN);
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) buf);
ok(lstrcmpW(buf, TestItem2) == 0,
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
/* When there is enough space for one character, but not both, of the CRLF
pair at the end of the string, the CR is not copied at all. That is,
the caller must not see CRLF pairs truncated to CR at the end of the
string.
*/
getText.cb = (lstrlenW(TestItem2) + 1) * sizeof(WCHAR);
getText.codepage = 1200; /* no constant for unicode */
getText.flags = GT_USECRLF; /* <-- asking for CR -> CRLF conversion */
getText.lpDefaultChar = NULL;
getText.lpUsedDefaultChar = NULL;
memset(buf, 0, MAX_BUF_LEN);
SendMessage(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM) buf);
ok(lstrcmpW(buf, TestItem1) == 0,
"EM_GETTEXTEX results not what was set by EM_SETTEXTEX\n");
/* \r\n pairs get changed into \r */
setText.codepage = 1200; /* no constant for unicode */
getText.codepage = 1200; /* no constant for unicode */