Skip to content

Commit 2de7290

Browse files
authored
Merge branch 'master' into add-api-issues-subscriptions
2 parents 7c24ae3 + 5598030 commit 2de7290

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

routers/repo/view.go

+5
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
307307
var output bytes.Buffer
308308
lines := strings.Split(fileContent, "\n")
309309
ctx.Data["NumLines"] = len(lines)
310+
if len(lines) == 1 && lines[0] == "" {
311+
// If the file is completely empty, we show zero lines at the line counter
312+
ctx.Data["NumLines"] = 0
313+
}
314+
ctx.Data["NumLinesSet"] = true
310315

311316
//Remove blank line at the end of file
312317
if len(lines) > 0 && lines[len(lines)-1] == "" {

templates/repo/view_file.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<strong>{{.FileName}}</strong>
77
{{else}}
88
<div class="file-info text grey normal mono">
9-
{{if .NumLines}}
9+
{{if .NumLinesSet}}
1010
<div class="file-info-entry">
1111
{{.NumLines}} {{.i18n.Tr (TrN .i18n.Lang .NumLines "repo.line" "repo.lines") }}
1212
</div>

0 commit comments

Comments
 (0)