Skip to content

Commit

Permalink
Added deletion of an empty line at the end of the file (go-gitea#4050)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
  • Loading branch information
axifive committed May 26, 2018
1 parent 2eabf18 commit 5f26ebc
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions routers/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st

var output bytes.Buffer
lines := strings.Split(fileContent, "\n")
//Remove blank line at the end of file
if len(lines) > 0 && lines[len(lines)-1] == "" {
lines = lines[:len(lines)-1]
}
for index, line := range lines {
line = gotemplate.HTMLEscapeString(line)
if index != len(lines)-1 {
Expand Down

1 comment on commit 5f26ebc

@axifive
Copy link
Owner Author

@axifive axifive commented on 5f26ebc May 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the last end of line (EOL), and some text displaying software hide it. For the web/desktop editors, it is normal to show last blank line. You can check this behavior on github and gitlab

Please sign in to comment.