From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47305 Signed-off-by: Fabian Maurer dark.shadow4@web.de Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/comctl32/edit.c | 6 +----- dlls/comctl32/tests/edit.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index bdd3b72558..d02d7af7b9 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -1038,12 +1038,8 @@ static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap) lw = line_def->width; w = es->format_rect.right - es->format_rect.left; if (line_def->ssa) - { ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x); - x -= es->x_offset; - } - else - x = es->x_offset; + x -= es->x_offset;
if (es->style & ES_RIGHT) x = w - (lw - x); diff --git a/dlls/comctl32/tests/edit.c b/dlls/comctl32/tests/edit.c index 3fe208c321..cec6025077 100644 --- a/dlls/comctl32/tests/edit.c +++ b/dlls/comctl32/tests/edit.c @@ -1189,6 +1189,8 @@ static void test_char_from_pos(void) { int lo, hi, mid, ret, i; HWND hwEdit; + HDC dc; + SIZE size;
hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM)"aa"); @@ -1321,6 +1323,24 @@ static void test_char_from_pos(void) ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0); ok(-1 == ret, "expected -1 got %d\n", ret); DestroyWindow(hwEdit); + + /* Scrolled to the right with partially visible line, position on next line. */ + hwEdit = create_editcontrol(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + + dc = GetDC(hwEdit); + GetTextExtentPoint32A(dc, "w", 1, &size); + ReleaseDC(hwEdit, dc); + + SetWindowPos(hwEdit, NULL, 0, 0, size.cx * 15, size.cy * 5, SWP_NOMOVE | SWP_NOZORDER); + SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM)"wwwwwwwwwwwwwwwwwwww\r\n\r\n"); + SendMessageA(hwEdit, EM_SETSEL, 40, 40); + + lo = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 22, 0); + ret = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 20, 0); + ret -= 20 * size.cx; /* Calculate expected position, 20 characters back. */ + ok(ret == lo, "Unexpected position %d vs %d.\n", lo, ret); + + DestroyWindow(hwEdit); }
/* Test if creating edit control without ES_AUTOHSCROLL and ES_AUTOVSCROLL
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47305 Signed-off-by: Fabian Maurer dark.shadow4@web.de Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/edit.c | 6 +----- dlls/user32/tests/edit.c | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index 00900e648b..557a091c0d 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -1097,12 +1097,8 @@ static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap) lw = line_def->width; w = es->format_rect.right - es->format_rect.left; if (line_def->ssa) - { ScriptStringCPtoX(line_def->ssa, (index - 1) - li, TRUE, &x); - x -= es->x_offset; - } - else - x = es->x_offset; + x -= es->x_offset;
if (es->style & ES_RIGHT) x = w - (lw - x); diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c index d0374c02a3..e3ed3341d6 100644 --- a/dlls/user32/tests/edit.c +++ b/dlls/user32/tests/edit.c @@ -1136,12 +1136,14 @@ static void test_edit_control_3(void)
/* Test EM_CHARFROMPOS and EM_POSFROMCHAR */ -static void test_edit_control_4(void) +static void test_char_from_pos(void) { HWND hwEdit; int lo, hi, mid; int ret; int i; + HDC dc; + SIZE size;
trace("EDIT: Test EM_CHARFROMPOS and EM_POSFROMCHAR\n"); hwEdit = create_editcontrol(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); @@ -1251,6 +1253,24 @@ static void test_edit_control_4(void) ret = SendMessageA(hwEdit, EM_POSFROMCHAR, 2, 0); ok(-1 == ret, "expected -1 got %d\n", ret); DestroyWindow(hwEdit); + + /* Scrolled to the right with partially visible line, position on next line. */ + hwEdit = create_editcontrol(ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + + dc = GetDC(hwEdit); + GetTextExtentPoint32A(dc, "w", 1, &size); + ReleaseDC(hwEdit, dc); + + SetWindowPos(hwEdit, NULL, 0, 0, size.cx * 15, size.cy * 5, SWP_NOMOVE | SWP_NOZORDER); + SendMessageA(hwEdit, WM_SETTEXT, 0, (LPARAM)"wwwwwwwwwwwwwwwwwwww\r\n\r\n"); + SendMessageA(hwEdit, EM_SETSEL, 40, 40); + + lo = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 22, 0); + ret = (short)SendMessageA(hwEdit, EM_POSFROMCHAR, 20, 0); + ret -= 20 * size.cx; /* Calculate expected position, 20 characters back. */ + ok(ret == lo, "Unexpected position %d vs %d.\n", lo, ret); + + DestroyWindow(hwEdit); }
/* Test if creating edit control without ES_AUTOHSCROLL and ES_AUTOVSCROLL @@ -3243,7 +3263,7 @@ START_TEST(edit) test_edit_control_1(); test_edit_control_2(); test_edit_control_3(); - test_edit_control_4(); + test_char_from_pos(); test_edit_control_5(); test_edit_control_6(); test_edit_control_limittext();
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=59455
Your paranoid android.
=== debian10 (32 bit Chinese:China report) ===
user32: clipboard.c:717: Test failed: 7: gle 5 clipboard.c:719: Test failed: 7: gle 1418 clipboard.c:746: Test failed: 7: count 3 clipboard.c:749: Test failed: 7: gle 1418 clipboard.c:765: Test failed: 7.0: got 0008 instead of 0011