[PATCH 3/3] riched32: On VK_RETURN don't add newline into text

Huw Davies huw at codeweavers.com
Mon Dec 10 06:56:21 CST 2018


On Sun, Dec 09, 2018 at 11:51:57PM +0100, Fabian Maurer wrote:
> This fixes an old regression when VK_RETURN handling was implemented
> 
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=23282
> Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
> ---
>  dlls/riched20/editor.c       |  4 ++++
>  dlls/riched20/tests/editor.c | 31 +++++++++++++++++++++++++++++++
>  dlls/riched32/tests/editor.c | 31 +++++++++++++++++++++++++++++++
>  3 files changed, 66 insertions(+)
> 
> diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
> index 9142fd917d..8dc1a01f70 100644
> --- a/dlls/riched20/editor.c
> +++ b/dlls/riched20/editor.c
> @@ -2658,6 +2658,7 @@ ME_KeyDown(ME_TextEditor *editor, WORD nKey)
>        ME_SendRequestResize(editor, FALSE);
>        return TRUE;
>      case VK_RETURN:
> +      if (!editor->bEmulateVersion10)
>        {
>            INT result = handle_enter(editor);
>            if (result != -1)
> @@ -2732,6 +2733,9 @@ static LRESULT ME_Char(ME_TextEditor *editor, WPARAM charCode,
>  {
>    WCHAR wstr;
>  
> +  if (editor->bEmulateVersion10 && charCode == '\r')
> +      handle_enter(editor);
> +
>    if (editor->bMouseCaptured)
>      return 0;
>  
> diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
> index 5c2df7f86c..690c9b6e67 100644
> --- a/dlls/riched20/tests/editor.c
> +++ b/dlls/riched20/tests/editor.c
> @@ -8273,6 +8273,7 @@ static void format_test_result(char *target, const char *src)
>   * inserts CR. If shows that EM_GETTEXTEX with GT_USECRLF == WM_GETTEXT
>   * and also shows that GT_USECRLF has no effect in richedit 1.0, but
>   * does for higher. The same test is cloned in riched32 and riched20.
> + * Also shows the difference between WM_CHAR/WM_KEYDOWN in v1.0 and higher versions
>   */
>  static void test_enter(void)
>  {
> @@ -8353,6 +8354,36 @@ static void test_enter(void)
>          i, resultbuf, expectedbuf);
>    }
>  
> +  /* Show that WM_CHAR is handled differently from WM_KEYDOWN */
> +  getText.flags    = GT_DEFAULT;
> +  getText.codepage = CP_ACP;
> +
> +  result = SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"");
> +  ok (result == 1, "[%d] WM_SETTEXT returned %ld instead of 1\n", i, result);
> +  SendMessageW(hwndRichEdit, WM_CHAR, 'T', 0);
> +  SendMessageW(hwndRichEdit, WM_KEYDOWN, VK_RETURN, 0);
> +
> +  SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);

Testing the return value would be good.

> +  format_test_result(resultbuf, buf);
> +  format_test_result(expectedbuf, "T\r");
> +  result = strcmp(resultbuf, expectedbuf);
> +  ok (result == 0 || broken(buf[0]==0x00 /* WinNT4 */),

You can drop the broken nt4 tests.

> +
> +  result = SendMessageA(hwndRichEdit, EM_GETTEXTEX, (WPARAM)&getText, (LPARAM)buf);

Would be good to test result here too.

> +  format_test_result(resultbuf, buf);
> +  format_test_result(expectedbuf, "T");
> +  result = strcmp(resultbuf, expectedbuf);
> +  ok (result == 0 || broken(buf[0]==0x00 /* WinNT4 */),
> +      "[%d] EM_GETTEXTEX, GT_DEFAULT unexpected '%s', expected '%s'\n",
> +      i, resultbuf, expectedbuf);
> +
>    DestroyWindow(hwndRichEdit);
>  }
>  

Huw.




More information about the wine-devel mailing list