Ticket #886: textview.patch

File textview.patch, 864 bytes (added by jackburton, 17 years ago)

Bug Fix

  • TextView.cpp

     
    14901490        NormalizeFont(&newFont);
    14911491    }
    14921492
     1493    const int32 textLength = fText->Length();
     1494
    14931495    if (!fStylable) {
    14941496        // When the text view is not stylable, we always set the whole text's
    14951497        // style and ignore the offsets
    14961498        startOffset = 0;
    1497         endOffset = fText->Length();
     1499        endOffset = textLength;
    14981500    }
    14991501
     1502    // pin offsets at reasonable values
     1503    if (startOffset < 0)
     1504        startOffset = 0;
     1505    else if (startOffset > textLength)
     1506        startOffset = textLength;
     1507
     1508    if (endOffset < 0)
     1509        endOffset = 0;
     1510    else if (endOffset > textLength)
     1511        endOffset = textLength;
     1512
    15001513    // add the style to the style buffer
    15011514    fStyles->SetStyleRange(startOffset, endOffset, fText->Length(),
    15021515        fontMode, &newFont, color);