Huw Davies : riched20: Ensure the cursors are correctly ordered in the case of a zero (logical) length selection bridging two runs.
Alexandre Julliard
julliard at winehq.org
Fri Jan 10 14:44:58 CST 2014
Module: wine
Branch: stable
Commit: 333365369674b7f1f8d00be4d0c6686c235100a0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=333365369674b7f1f8d00be4d0c6686c235100a0
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Dec 10 11:19:08 2013 +0000
riched20: Ensure the cursors are correctly ordered in the case of a zero (logical) length selection bridging two runs.
(cherry picked from commit b0f177b61913b9fac1cf8952582d77576705bad1)
---
dlls/riched20/caret.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/riched20/caret.c b/dlls/riched20/caret.c
index fd7034d..4b1fea5 100644
--- a/dlls/riched20/caret.c
+++ b/dlls/riched20/caret.c
@@ -56,7 +56,19 @@ int ME_GetSelectionOfs(ME_TextEditor *editor, int *from, int *to)
int ME_GetSelection(ME_TextEditor *editor, ME_Cursor **from, ME_Cursor **to)
{
- if (ME_GetCursorOfs(&editor->pCursors[0]) < ME_GetCursorOfs(&editor->pCursors[1]))
+ int from_ofs = ME_GetCursorOfs( &editor->pCursors[0] );
+ int to_ofs = ME_GetCursorOfs( &editor->pCursors[1] );
+ BOOL swap = (from_ofs > to_ofs);
+
+ if (from_ofs == to_ofs)
+ {
+ /* If cursor[0] is at the beginning of a run and cursor[1] at the end
+ of the prev run then we need to swap. */
+ if (editor->pCursors[0].nOffset < editor->pCursors[1].nOffset)
+ swap = TRUE;
+ }
+
+ if (!swap)
{
*from = &editor->pCursors[0];
*to = &editor->pCursors[1];
More information about the wine-cvs
mailing list