diff options
author | Lukas <LukBukkit@users.noreply.github.com> | 2019-10-29 17:05:26 +0100 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-10-29 16:05:26 +0000 |
commit | 559803025df56b540137e3e3fff262433bee57af (patch) | |
tree | e822f69c8cfdbd8f48c71d6c19c12bd6ccf0704b /routers | |
parent | 9513a6983a9b0a025dc77ffdbc559f1550e3f7dd (diff) | |
download | gitea-559803025df56b540137e3e3fff262433bee57af.tar.gz gitea-559803025df56b540137e3e3fff262433bee57af.zip |
Show zero lines on the line counter if the file empty (#8700)
* Show zero lines on the line counter if the file empty
Signed-off-by: LukBukkit <luk.bukkit@gmail.com>
* A single variable to check whether NumLines is set
Signed-off-by: LukBukkit <luk.bukkit@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/view.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/routers/repo/view.go b/routers/repo/view.go index a2e431e435..da6d426de4 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -307,6 +307,11 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st var output bytes.Buffer lines := strings.Split(fileContent, "\n") ctx.Data["NumLines"] = len(lines) + if len(lines) == 1 && lines[0] == "" { + // If the file is completely empty, we show zero lines at the line counter + ctx.Data["NumLines"] = 0 + } + ctx.Data["NumLinesSet"] = true //Remove blank line at the end of file if len(lines) > 0 && lines[len(lines)-1] == "" { |