TextDocumentLayout: Text offset at end of last paragraph...
... now yields the last paragraph index and does not subtract the paragraph length from the text offset.
This commit is contained in:
parent
38c65defc5
commit
e9d9561cfb
|
@ -336,7 +336,7 @@ TextDocumentLayout::_ParagraphLayoutIndexForOffset(int32& textOffset)
|
||||||
_ValidateLayout();
|
_ValidateLayout();
|
||||||
|
|
||||||
int32 paragraphs = fParagraphLayouts.CountItems();
|
int32 paragraphs = fParagraphLayouts.CountItems();
|
||||||
for (int32 i = 0; i < paragraphs; i++) {
|
for (int32 i = 0; i < paragraphs - 1; i++) {
|
||||||
const ParagraphLayoutInfo& info = fParagraphLayouts.ItemAtFast(i);
|
const ParagraphLayoutInfo& info = fParagraphLayouts.ItemAtFast(i);
|
||||||
|
|
||||||
int32 length = info.layout->CountGlyphs();
|
int32 length = info.layout->CountGlyphs();
|
||||||
|
@ -348,6 +348,16 @@ TextDocumentLayout::_ParagraphLayoutIndexForOffset(int32& textOffset)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paragraphs > 0) {
|
||||||
|
const ParagraphLayoutInfo& info = fParagraphLayouts.LastItem();
|
||||||
|
|
||||||
|
// Return last paragraph if the textOffset is still within or
|
||||||
|
// exactly behind the last valid offset in that paragraph.
|
||||||
|
int32 length = info.layout->CountGlyphs();
|
||||||
|
if (textOffset <= length)
|
||||||
|
return paragraphs - 1;
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue