Commit 68b9018d authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

riched20: Fix ME_SetSelection when cpMax > strlen().

parent e73bd253
......@@ -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;
}
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment