diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c index 4b4db9fd2b1..3121293edb7 100644 --- a/dlls/riched20/editor.c +++ b/dlls/riched20/editor.c @@ -2702,12 +2702,30 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam, ME_DisplayItem *item = editor->pBuffer->pFirst->next; int nRows = 0; + ME_DisplayItem *prev_para = NULL, *last_para = NULL; + while (item != editor->pBuffer->pLast) { assert(item->type == diParagraph); + prev_para = ME_FindItemBack(item, diRun); + if (prev_para) { + assert(prev_para->member.run.nFlags & MERF_ENDPARA); + } nRows += item->member.para.nRows; item = item->member.para.next_para; } + last_para = ME_FindItemBack(item, diRun); + assert(last_para); + assert(last_para->member.run.nFlags & MERF_ENDPARA); + if (editor->bEmulateVersion10 && prev_para && last_para->member.run.nCharOfs == 0 + && prev_para->member.run.nCR == 1 && prev_para->member.run.nLF == 0) + { + /* In 1.0 emulation, the last solitary \r at the very end of the text + (if one exists) is NOT a line break. + FIXME: this is an ugly hack. This should have a more regular model. */ + nRows--; + } + TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows); return max(1, nRows); } diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c index 70d15585a4e..abecaee2b07 100644 --- a/dlls/riched32/tests/editor.c +++ b/dlls/riched32/tests/editor.c @@ -110,8 +110,8 @@ static void test_WM_SETTEXT() } TEST_SETTEXT(TestItem1, TestItem1, 1, 0, 0) - TEST_SETTEXT(TestItem2, TestItem2, 1, 0, 1) - TEST_SETTEXT(TestItem3, TestItem3, 2, 0, 1) + TEST_SETTEXT(TestItem2, TestItem2, 1, 0, 0) + TEST_SETTEXT(TestItem3, TestItem3, 2, 0, 0) TEST_SETTEXT(TestItem4, TestItem4, 3, 0, 0) TEST_SETTEXT(TestItem5, TestItem5, 2, 0, 0) TEST_SETTEXT(TestItem6, TestItem6, 3, 0, 0) @@ -123,7 +123,7 @@ static void test_WM_SETTEXT() TEST_SETTEXT(TestItem12, TestItem12, 2, 0, 0) TEST_SETTEXT(TestItem13, TestItem13, 3, 0, 0) TEST_SETTEXT(TestItem14, TestItem14, 2, 0, 0) - TEST_SETTEXT(TestItem15, TestItem15, 3, 0, 1) + TEST_SETTEXT(TestItem15, TestItem15, 3, 0, 0) TEST_SETTEXT(TestItem16, TestItem16, 4, 0, 0) #undef TEST_SETTEXT