Do not add a trailing newline when wrapping
This commit is contained in:
parent
e42b4fd9a6
commit
924cd4cadd
@ -37,6 +37,7 @@ func (self *Command) ShowVersion() {
|
||||
func format_with_indent(output io.Writer, text string, indent string, screen_width int) {
|
||||
indented := style.WrapText(text, indent, screen_width, "#placeholder_for_formatting#")
|
||||
io.WriteString(output, indented)
|
||||
io.WriteString(output, "\n")
|
||||
}
|
||||
|
||||
func (self *Command) FormatSubCommands(output io.Writer, formatter *markup.Context, screen_width int) {
|
||||
|
||||
@ -235,11 +235,7 @@ func lines_for_context_chunk(data *DiffData, hunk_num int, chunk *Chunk, chunk_n
|
||||
}
|
||||
|
||||
func splitlines(text string, width int) []string {
|
||||
lines := style.WrapTextAsLines(text, "", width)
|
||||
if len(lines) > 1 && lines[len(lines)-1] == "" {
|
||||
lines = lines[:len(lines)-1]
|
||||
}
|
||||
return lines
|
||||
return style.WrapTextAsLines(text, "", width)
|
||||
}
|
||||
|
||||
func render_half_line(line_number int, line, ltype string, margin_size, available_cols int, center Center, ans []string) []string {
|
||||
|
||||
@ -481,7 +481,9 @@ func (self *wrapper) wrap_text(text string) []string {
|
||||
if last_line == self.current_line.reset() {
|
||||
last_line = ""
|
||||
}
|
||||
self.append_line(last_line)
|
||||
if last_line != "" {
|
||||
self.append_line(last_line)
|
||||
}
|
||||
return self.lines
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ func TestFormatWithIndent(t *testing.T) {
|
||||
screen_width := 11
|
||||
|
||||
tx := func(text string, expected ...string) {
|
||||
q := indent + strings.Join(expected, "") + "\n"
|
||||
q := indent + strings.Join(expected, "")
|
||||
actual := WrapText(text, indent, screen_width)
|
||||
if actual != q {
|
||||
t.Fatalf("%#v\nexpected: %#v\nactual: %#v", text, q, actual)
|
||||
@ -35,4 +35,6 @@ func TestFormatWithIndent(t *testing.T) {
|
||||
screen_width = 3
|
||||
tx("one", "one")
|
||||
tx("four", "fou\nr")
|
||||
tx("nl\n\n", "nl\n\n")
|
||||
tx("four\n\n", "fou\nr\n\n")
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user