Skip to content

Commit

Permalink
show: Fix bug with multi-line discussion comment output
Browse files Browse the repository at this point in the history
Currently when outputting a multi-line comment in a discussion the output
looks like

    prarit commented at 2020-09-25 15:47:37.445 +0000 UTC

    The
quick
brown
fox
jumps

When it should be

    prarit commented at 2020-09-25 15:47:37.445 +0000 UTC

    The
    quick
    brown
    fox
    jumps

This occurs because only the first line the note Body is "tabbed" over.
Each newline should be tabbed over as well.

Fix bug with multi-line discussion comment output.

Signed-off-by: Prarit Bhargava <[email protected]>
  • Loading branch information
prarit committed Sep 26, 2020
1 parent 4353b94 commit a048e20
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/issue_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ func PrintDiscussions(discussions []*gitlab.Discussion, since string, idstr stri
indentHeader = " "
}
}

noteBody := strings.Replace(note.Body, "\n", "\n"+indentHeader, -1)
printit := color.New().PrintfFunc()
printit(`
%s-----------------------------------`, indentHeader)
Expand All @@ -176,7 +178,7 @@ func PrintDiscussions(discussions []*gitlab.Discussion, since string, idstr stri
%s%s
`,
indentHeader, note.ID, note.Author.Username, commented, time.Time(*note.UpdatedAt).String(),
indentNote, note.Body)
indentNote, noteBody)
}
}

Expand Down

0 comments on commit a048e20

Please sign in to comment.