···562562 // empty: 0 lines; "a": 1 line; "a\n": 1 line; "a\nb": 2 lines;
563563 // When rendering, the last empty line is not rendered in U and isn't counted towards the number of lines.
564564 // To tell users that the file not contains a trailing EOL, text with a tooltip is displayed in the file header.
565565+ // Trailing EOL is only considered if the file has content.
565566 // This NumLines is only used for the display on the UI: "xxx lines"
566566- hasTrailingEOL := bytes.HasSuffix(buf, []byte{'\n'})
567567- ctx.Data["HasTrailingEOL"] = hasTrailingEOL
568568- ctx.Data["HasTrailingEOLSet"] = true
569567 if len(buf) == 0 {
570568 ctx.Data["NumLines"] = 0
571569 } else {
570570+ hasNoTrailingEOL := !bytes.HasSuffix(buf, []byte{'\n'})
571571+ ctx.Data["HasNoTrailingEOL"] = hasNoTrailingEOL
572572+572573 numLines := bytes.Count(buf, []byte{'\n'})
573573- if !hasTrailingEOL {
574574+ if hasNoTrailingEOL {
574575 numLines++
575576 }
576577 ctx.Data["NumLines"] = numLines