Changeset 3608

Show
Ignore:
Timestamp:
03/10/07 02:17:08 (1 year ago)
Author:
timothy
Message:

Fixes the highlight marks being off once the scrollback limit was reached. #708

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Views/JVStyleView.m

    r3606 r3608  
    815815        transformedMessage = nil; 
    816816 
    817         long shiftAmount = 0; 
    818         // check how much we need to shift the scrollbar marks 
    819         if( ! consecutive && messageCount > scrollbackLimit ) 
    820                 shiftAmount = [self _locationOfElementAtIndex:( messageCount - scrollbackLimit )]; 
    821  
    822         // enforce the scrollback limit 
     817        // enforce the scrollback limit and shift scrollbar marks 
    823818        if( scrollToBottomNeeded && scrollbackLimit > 0 && messageCount > scrollbackLimit ) { 
    824                 for( unsigned int i = 0; messageCount > scrollbackLimit && i < ( messageCount - scrollbackLimit ); i++ ) { 
    825                         [_body removeChild:[_body firstChild]]; 
    826                         messageCount--; 
     819                unsigned limit = ( messageCount - scrollbackLimit ); 
     820                long shiftAmount = [self _locationOfElementAtIndex:limit]; 
     821 
     822                DOMNode *node = [_body firstChild]; 
     823                for( unsigned i = 0; node && i < limit; ) { 
     824                        DOMNode *next = [node nextSibling]; 
     825 
     826                        if( [node nodeType] == DOM_ELEMENT_NODE ) { 
     827                                [_body removeChild:node]; 
     828                                ++i; 
     829                        } 
     830 
     831                        node = next; 
    827832                } 
    828         } 
    829  
    830         if( scrollToBottomNeeded && shiftAmount > 0 && shiftAmount != NSNotFound ) { 
    831                 DOMHTMLElement *body = [_domDocument body]; 
    832                 unsigned long scrollTop = [[body valueForKey:@"scrollTop"] longValue]; 
    833                 [body setValue:[NSNumber numberWithUnsignedLong:( scrollTop - shiftAmount )] forKey:@"scrollTop"]; 
    834                 [scroller shiftMarksAndShadedAreasBy:( shiftAmount * -1 )]; 
    835         } 
    836  
    837         [[self verticalMarkedScroller] setNeedsDisplay:YES]; 
     833 
     834                long firstItemShift = [self _locationOfElementAtIndex:0]; 
     835                if( firstItemShift != NSNotFound ) shiftAmount -= firstItemShift; 
     836 
     837                if( scrollToBottomNeeded && shiftAmount > 0 && shiftAmount != NSNotFound ) 
     838                        [scroller shiftMarksAndShadedAreasBy:( shiftAmount * -1 )]; 
     839        } 
    838840 
    839841        if( scrollToBottomNeeded ) [self scrollToBottom];