Skip to content

Commit e4313fe

Browse files
authored
Document the line-number counting behavior (#27386)
Ref #27377
1 parent 4999d90 commit e4313fe

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

routers/web/repo/view.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,8 +488,13 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
488488
} else {
489489
buf, _ := io.ReadAll(rd)
490490

491-
// empty: 0 lines; "a": one line; "a\n": two lines; "a\nb": two lines;
492-
// the NumLines is only used for the display on the UI: "xxx lines"
491+
// The Open Group Base Specification: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html
492+
// empty: 0 lines; "a": 1 line, 1 incomplete-line; "a\n": 1 line; "a\nb": 1 line, 1 incomplete-line;
493+
// Gitea uses the definition (like most modern editors):
494+
// empty: 0 lines; "a": 1 line; "a\n": 2 lines; "a\nb": 2 lines;
495+
// When rendering, the last empty line is not rendered in UI, while the line-number is still counted, to tell users that the file contains a trailing EOL.
496+
// To make the UI more consistent, it could use an icon mark to indicate that there is no trailing EOL, and show line-number as the rendered lines.
497+
// This NumLines is only used for the display on the UI: "xxx lines"
493498
if len(buf) == 0 {
494499
ctx.Data["NumLines"] = 0
495500
} else {

0 commit comments

Comments
 (0)