richedit: Handle case for EM_LINELENGTH when offset is between \r\n.

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.
This commit is contained in:
Dylan Smith 2009-01-27 03:39:03 -05:00 committed by Alexandre Julliard
parent 83ff6a5c5d
commit c94e78a572
2 changed files with 6 additions and 9 deletions

View File

@ -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)

View File

@ -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);