Commit f34cb461 authored by Clinton Stimpson's avatar Clinton Stimpson Committed by Alexandre Julliard

riched20: Only WM_CHAR respects text limit.

parent ebd1ba80
......@@ -441,7 +441,7 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
{
const WCHAR *pos;
ME_Cursor *p = NULL;
int freeSpace;
int oldLen;
/* FIXME really HERE ? */
if (ME_IsSelection(editor))
......@@ -449,7 +449,7 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
/* FIXME: is this too slow? */
/* Didn't affect performance for WM_SETTEXT (around 50sec/30K) */
freeSpace = editor->nTextLimit - ME_GetTextLength(editor);
oldLen = ME_GetTextLength(editor);
/* text operations set modified state */
editor->nModifyStep = 1;
......@@ -459,7 +459,11 @@ void ME_InsertTextFromCursor(ME_TextEditor *editor, int nCursor,
assert(nCursor>=0 && nCursor<editor->nCursors);
if (len == -1)
len = lstrlenW(str);
len = min(len, freeSpace);
/* grow the text limit to fit our text */
if(editor->nTextLimit < oldLen +len)
editor->nTextLimit = oldLen + len;
while (len)
{
pos = str;
......
......@@ -2413,11 +2413,17 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
}
if (((unsigned)wstr)>=' ' || wstr=='\r' || wstr=='\t') {
/* FIXME maybe it would make sense to call EM_REPLACESEL instead ? */
ME_Style *style = ME_GetInsertStyle(editor, 0);
ME_SaveTempStyle(editor);
ME_InsertTextFromCursor(editor, 0, &wstr, 1, style);
ME_ReleaseStyle(style);
ME_CommitUndo(editor);
/* WM_CHAR is restricted to nTextLimit */
int from, to;
ME_GetSelection(editor, &from, &to);
if(editor->nTextLimit > ME_GetTextLength(editor) - (to-from))
{
ME_Style *style = ME_GetInsertStyle(editor, 0);
ME_SaveTempStyle(editor);
ME_InsertTextFromCursor(editor, 0, &wstr, 1, style);
ME_ReleaseStyle(style);
ME_CommitUndo(editor);
}
ME_UpdateRepaint(editor);
}
return 0;
......
......@@ -1116,26 +1116,18 @@ static void test_EM_EXLIMITTEXT(void)
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
i = strlen(buffer);
todo_wine {
ok(10 == i, "expected 10 chars\n");
}
i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
todo_wine {
ok(10 == i, "EM_EXLIMITTEXT: expected: %d, actual: %d\n", 10, i);
}
/* try inserting more text at end */
i = SendMessage(hwndRichEdit, WM_CHAR, 'A', 0);
ok(0 == i, "WM_CHAR wasn't processed");
SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
i = strlen(buffer);
todo_wine {
ok(10 == i, "expected 10 chars, got %i\n", i);
}
i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
todo_wine {
ok(10 == i, "EM_EXLIMITTEXT: expected: %d, actual: %d\n", 10, i);
}
/* try inserting text at beginning */
SendMessage(hwndRichEdit, EM_SETSEL, 0, 0);
......@@ -1143,13 +1135,9 @@ todo_wine {
ok(0 == i, "WM_CHAR wasn't processed");
SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
i = strlen(buffer);
todo_wine {
ok(10 == i, "expected 10 chars, got %i\n", i);
}
i = SendMessage(hwndRichEdit, EM_GETLIMITTEXT, 0, 0);
todo_wine {
ok(10 == i, "EM_EXLIMITTEXT: expected: %d, actual: %d\n", 10, i);
}
/* WM_CHAR is limited */
textlimit = 1;
......
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