diff --git a/AppKit/CPTextView/CPTypesetter.j b/AppKit/CPTextView/CPTypesetter.j index 427d75586..aa7e39128 100644 --- a/AppKit/CPTextView/CPTypesetter.j +++ b/AppKit/CPTextView/CPTypesetter.j @@ -135,36 +135,34 @@ var CPSystemTypesetterFactory, return [_layoutManager textContainers]; } -// Retrieves correct CPTextTab stop accounting for CPArray properties - (CPTextTab)textTabForWidth:(double)aWidth writingDirection:(CPWritingDirection)direction { var tabStops = [_currentParagraph tabStops]; if (!tabStops) - tabStops = [[CPParagraphStyle defaultParagraphStyle] tabStops]; + tabStops = [CPParagraphStyle _defaultTabStops]; - var l = [tabStops count]; + var l = tabStops.length; - if (l === 0) + if (aWidth > tabStops[l - 1]._location) return nil; - // Find the first tab stop that is strictly greater than the current width - for (var i = 0; i < l; i++) + for (var i = l - 1; i >= 0; i--) { - var tab = [tabStops objectAtIndex:i]; - - if ([tab location] > aWidth) - return tab; + if (aWidth > tabStops[i]._location) + { + if (i + 1 < l) + return tabStops[i + 1]; + } } - // If aWidth exceeds the last tab stop, dynamically calculate the next - // tab location using the default tab interval. - var defaultInterval = [_currentParagraph defaultTabInterval] || 28.0; - var nextLocation = CEIL((aWidth + 1.0) / defaultInterval) * defaultInterval; + if (i === -1) + return tabStops[0]; - return [[CPTextTab alloc] initWithType:CPLeftTextAlignment location:nextLocation]; + return nil; } + - (BOOL)_flushRange:(CPRange)lineRange lineOrigin:(CGPoint)lineOrigin currentContainer:(CPTextContainer)aContainer