Fix line number count in line numbers view (fix #524)

This commit is contained in:
1024jp 2016-03-11 00:01:48 +09:00
parent 135385e70f
commit 4a5b6fa92f
2 changed files with 4 additions and 3 deletions

View File

@ -30,6 +30,7 @@ develop
- Fix an issue where “Delimit by whitespace” option on text find didn't work.
- Fix an issue where some document file information displayed wrong after saving.
- Fix an issue where line number view could count wrong if wrapped.
- Fix an issue where “ignore case” option in syntax style definition didn't actually ignore case.
- Fix an issue where the current file extension was omitted from new suggested file name on “Save As…” operation.
- Fix some typos in German localization. (Thanks to Chris Eidhof!)

View File

@ -260,12 +260,12 @@ static CGFontRef BoldLineNumberFont;
// counters
NSUInteger glyphCount = visibleGlyphRange.location;
NSUInteger lineNumber = 1;
NSUInteger lineNumber = 0;
NSUInteger lastLineNumber = 0;
// count lines until visible
lineNumber += [string numberOfLinesInRange:NSMakeRange(0, [layoutManager characterIndexForGlyphAtIndex:visibleGlyphRange.location])
includingLastNewLine:NO];
lineNumber = [string numberOfLinesInRange:NSMakeRange(0, [layoutManager characterIndexForGlyphAtIndex:visibleGlyphRange.location])
includingLastNewLine:YES] ?: 1; // start with 1
// draw visible line numbers
for (NSUInteger glyphIndex = visibleGlyphRange.location; glyphIndex < NSMaxRange(visibleGlyphRange); lineNumber++) { // count "real" lines