[4/7] richedit: Handle case for EM_LINELENGTH when offset is between \r\n.
Dylan Smith
dylan.ah.smith at gmail.com
Tue Jan 27 02:39:03 CST 2009
I found that ME_FindItemAtOffset and ME_CursorFromCharOfs are used
almost identically, except for how they handle a character offset that
is between a carriage return and line feed. In this case
ME_CursorFromCharOfs sets the cursor's run offset to 0, but
ME_FindItemAtOffset instead returns the next run which is what was
causing ME_LINELENGTH to incorrectly return the length of the next
line.
---
dlls/riched20/editor.c | 7 ++++---
dlls/riched32/tests/editor.c | 8 ++------
2 files changed, 6 insertions(+), 9 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index f10dddc..86f89d0 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -3786,7 +3786,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
{
ME_DisplayItem *item, *item_end;
int nChars = 0, nThisLineOfs = 0, nNextLineOfs = 0;
-
+ ME_Cursor cursor;
+
if (wParam > ME_GetTextLength(editor))
return 0;
if (wParam == -1)
@@ -3794,8 +3795,8 @@ LRESULT ME_HandleMessage(ME_TextEditor *editor, UINT msg, WPARAM wParam,
FIXME("EM_LINELENGTH: returning number of unselected characters on lines with selection unsupported.\n");
return 0;
}
- item = ME_FindItemAtOffset(editor, diRun, wParam, NULL);
- item = ME_RowStart(item);
+ ME_CursorFromCharOfs(editor, wParam, &cursor);
+ item = ME_RowStart(cursor.pRun);
nThisLineOfs = ME_CharOfsFromRunOfs(editor, ME_FindItemFwd(item, diRun), 0);
item_end = ME_FindItemFwd(item, diStartRowOrParagraphOrEnd);
if (item_end->type == diStartRow)
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 113dbd0..7332536 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -454,12 +454,8 @@ static void test_EM_LINELENGTH(void)
for (i = 0; i < sizeof(offset_test)/sizeof(offset_test[0]); i++) {
result = SendMessage(hwndRichEdit, EM_LINELENGTH, offset_test[i][0], 0);
- if (i == 6)
- todo_wine ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
- offset_test[i][0], result, offset_test[i][1]);
- else
- ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
- offset_test[i][0], result, offset_test[i][1]);
+ ok(result == offset_test[i][1], "Length of line at offset %d is %ld, expected %d\n",
+ offset_test[i][0], result, offset_test[i][1]);
}
DestroyWindow(hwndRichEdit);
More information about the wine-patches
mailing list