                         drawTick(y: y)
                     }
                     if !isVerticalText || lineNumber % 5 == 0 || lineNumber == 1 || isSelected ||
-                        lineRange.upperBound == length && layoutManager.extraLineFragmentTextContainer == nil  // last line for vertical text
+                        (lineRange.upperBound == length && layoutManager.extraLineFragmentTextContainer == nil)  // last line for vertical text
                     {
                         drawLineNumber(lineNumber, y: y, isBold: isSelected)
                     }

        }
        
        // get glyph range of which line number should be drawn
        let visibleRect = self.scrollView?.documentVisibleRect ?? textView.frame
        let glyphRangeToDraw = layoutManager.glyphRange(forBoundingRectWithoutAdditionalLayout: visibleRect, in: textContainer)
        
        // count up lines until visible
        let undisplayedRange = NSRange(location: 0, length: layoutManager.characterIndexForGlyph(at: glyphRangeToDraw.location))
        var lineNumber = max(string.numberOfLines(in: undisplayedRange, includingLastLineEnding: true), 1)  // start with 1
        
        // draw visible line numbers
        var glyphCount = glyphRangeToDraw.location
        var glyphIndex = glyphRangeToDraw.location
        var lastLineNumber = 0
        

        // draw the last "extra" line number
        if layoutManager.extraLineFragmentTextContainer != nil {
            let isSelected: Bool = {
                guard let lastSelectedRange = selectedLineRanges.last else { return false }
                
                return (lastSelectedRange.length == 0) && (length == lastSelectedRange.upperBound)
            }()
            let lineRect = layoutManager.extraLineFragmentUsedRect
            let y = scale * -lineRect.minY
