Jactry Zeng : riched20: Fix ME_SetSelection when cpMax > strlen().

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 21 13:37:11 CDT 2014


Module: wine
Branch: master
Commit: 68b9018d50b7ef2d74c08a2562e8b670731f777f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=68b9018d50b7ef2d74c08a2562e8b670731f777f

Author: Jactry Zeng <wine at jactry.com>
Date:   Tue Jul 22 00:40:48 2014 +0800

riched20: Fix ME_SetSelection when cpMax > strlen().

---

 dlls/riched20/caret.c        | 13 ++++++++++++-
 dlls/riched20/tests/editor.c | 14 ++++++++------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index 90b30a2..043a32a 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -139,6 +139,7 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
   {
     ME_SetCursorToStart(editor, &editor->pCursors[1]);
     ME_SetCursorToEnd(editor, &editor->pCursors[0]);
+    editor->pCursors[0].nOffset = editor->pCursors[0].pRun->member.run.len;
     ME_InvalidateSelection(editor);
     return len + 1;
   }
@@ -159,6 +160,11 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
       ME_GetSelectionOfs(editor, &start, &end);
       if (start != end)
       {
+          if (end > len)
+          {
+              editor->pCursors[0].nOffset = 0;
+              end --;
+          }
           editor->pCursors[1] = editor->pCursors[0];
           ME_Repaint(editor);
       }
@@ -200,7 +206,12 @@ int ME_SetSelection(ME_TextEditor *editor, int from, int to)
   if (editor->pCursors[1].pRun->member.run.nFlags & MERF_ENDPARA)
     editor->pCursors[1].nOffset = 0;
   if (editor->pCursors[0].pRun->member.run.nFlags & MERF_ENDPARA)
-    editor->pCursors[0].nOffset = 0;
+  {
+    if (to > len)
+      editor->pCursors[0].nOffset = editor->pCursors[0].pRun->member.run.len;
+    else
+      editor->pCursors[0].nOffset = 0;
+  }
   return to;
 }
 
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 3bd3ec0..5ad063e 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -4363,7 +4363,9 @@ const struct exsetsel_s exsetsel_tests[] = {
   {5, 10, 10, 5, 10, 0},
   {15, 17, 17, 15, 17, 0},
   /* test cpMax > strlen() */
-  {0, 100, 18, 0, 18, 1},
+  {0, 100, 18, 0, 18, 0},
+  /* test cpMin < 0 && cpMax >= 0 after cpMax > strlen() */
+  {-1, 1, 17, 17, 17, 0},
   /* test cpMin == cpMax */
   {5, 5, 5, 5, 5, 0},
   /* test cpMin < 0 && cpMax >= 0 (bug 4462) */
@@ -4373,13 +4375,13 @@ const struct exsetsel_s exsetsel_tests[] = {
   /* test cpMin < 0 && cpMax < 0 */
   {-1, -1, 17, 17, 17, 0},
   {-4, -5, 17, 17, 17, 0},
-  /* test cMin >=0 && cpMax < 0 (bug 6814) */
-  {0, -1, 18, 0, 18, 1},
-  {17, -5, 18, 17, 18, 1},
+  /* test cpMin >=0 && cpMax < 0 (bug 6814) */
+  {0, -1, 18, 0, 18, 0},
+  {17, -5, 18, 17, 18, 0},
   {18, -3, 17, 17, 17, 0},
   /* test if cpMin > cpMax */
-  {15, 19, 18, 15, 18, 1},
-  {19, 15, 18, 15, 18, 1}
+  {15, 19, 18, 15, 18, 0},
+  {19, 15, 18, 15, 18, 0},
 };
 
 static void check_EM_EXSETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id) {




More information about the wine-cvs mailing list