Huw Davies : riched20: Use run ptrs in the EM_GETLINECOUNT handler.

Alexandre Julliard julliard at winehq.org
Mon Nov 2 16:21:19 CST 2020


Module: wine
Branch: master
Commit: d55bc24001b3354150e69184177070b0277649f5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d55bc24001b3354150e69184177070b0277649f5

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Nov  2 08:23:18 2020 +0000

riched20: Use run ptrs in the EM_GETLINECOUNT handler.

Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/riched20/editor.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index c01bd873634..66f6bd5e114 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -4291,27 +4291,24 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
   }
   case EM_GETLINECOUNT:
   {
-    ME_DisplayItem *item = editor->pBuffer->pLast;
-    int nRows = editor->total_rows;
-    ME_DisplayItem *prev_para = NULL, *last_para = NULL;
-
-    last_para = ME_FindItemBack(item, diRun);
-    prev_para = ME_FindItemBack(last_para, 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.len == 1 &&
-        *get_text( &prev_para->member.run, 0 ) == '\r')
+    int count = editor->total_rows;
+    ME_Run *prev_run, *last_run;
+
+    last_run = para_end_run( para_prev( editor_end_para( editor ) ) );
+    prev_run = run_prev_all_paras( last_run );
+
+    if (editor->bEmulateVersion10 && prev_run && last_run->nCharOfs == 0 &&
+        prev_run->len == 1 && *get_text( prev_run, 0 ) == '\r')
     {
       /* 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--;
+      count--;
     }
 
-    TRACE("EM_GETLINECOUNT: nRows==%d\n", nRows);
-    return max(1, nRows);
+    count = max(1, count);
+    TRACE("EM_GETLINECOUNT: count==%d\n", count);
+    return count;
   }
   case EM_LINEFROMCHAR:
   {




More information about the wine-cvs mailing list