@@ -183,12 +183,19 @@ class EditorTextView: UITextView, NSLayoutManagerDelegate {
183183
184184
185185 func dimLineUnderLocation( location: CGPoint ) {
186- let currentLine = lineNumberUnderPoint ( location)
186+ //let currentLine = lineNumberUnderPoint(location)
187+ let currentLine = Int ( ( location. y / ( font. lineHeight + lineSpacing) ) )
187188 slightlyDimLineWhileDraggingOver ( lineNumber: currentLine)
188189 }
189190
190191 func slightlyDimLineWhileDraggingOver( #lineNumber: Int) {
191- let FirstLineNumberRect = getLineNumberRect ( lineNumber)
192+ //let FirstLineNumberRect = getLineNumberRect(lineNumber)
193+ let LineHeight = font. lineHeight + lineSpacing
194+ let FirstLineNumberRect = CGRect (
195+ x: 0 ,
196+ y: LineHeight * CGFloat( lineNumber ) ,
197+ width: frame. width,
198+ height: LineHeight)
192199 let HighlightingRect = CGRect (
193200 x: FirstLineNumberRect . origin. x,
194201 y: FirstLineNumberRect . origin. y,
@@ -478,16 +485,23 @@ class EditorTextView: UITextView, NSLayoutManagerDelegate {
478485 stop. initialize ( true )
479486 }
480487 } else {
481- numberOfExtraLines++
488+ var characterRangeString = storage. string ( ) !. substringWithRange ( charRange) . stringByTrimmingCharactersInSet ( NSCharacterSet . newlineCharacterSet ( ) )
489+ if countElements ( characterRangeString) > 0 {
490+ numberOfExtraLines++
491+ }
492+
493+
482494 }
483495 }
484496 layoutManager. enumerateLineFragmentsForGlyphRange ( glyphsToShow,
485497 usingBlock: lineFragmentClosure)
486498 if boundingRect == nil {
499+ println ( lineNumber)
500+ println ( numberOfExtraLines)
487501 let LineHeight = font. lineHeight + lineSpacing
488502 let LineNumberRect = CGRect (
489503 x: 0 ,
490- y: LineHeight * CGFloat( lineNumber - numberOfExtraLines + 1 ) ,
504+ y: LineHeight * CGFloat( lineNumber - numberOfExtraLines) ,
491505 width: frame. width,
492506 height: LineHeight)
493507 boundingRect = LineNumberRect
0 commit comments