diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c index f5fbf000de7..47e816cc4cc 100644 --- a/dlls/riched20/caret.c +++ b/dlls/riched20/caret.c @@ -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 && nCursornCursors); 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; diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 3e1cdf2385d..dff0b5f61b9 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -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; diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index 98b355e17b0..5c0058610b0 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -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;