diff --git a/buffer/buffer.go b/buffer/buffer.go index 201931a..d4eb4ae 100644 --- a/buffer/buffer.go +++ b/buffer/buffer.go @@ -215,7 +215,7 @@ func (buffer *Buffer) GetSelectedText(selectionRegionMode SelectionRegionMode) s maxX := int(buffer.terminalState.viewWidth) - 1 if row == start.Line { minX = start.Col - } else if !line.wrapped { + } else if !line.wrapped && !line.nobreak { builder.WriteString("\n") } if row == end.Line { @@ -695,6 +695,7 @@ func (buffer *Buffer) Write(runes ...rune) { buffer.NewLineEx(true) newLine := buffer.getCurrentLine() + newLine.setNoBreak(true) if len(newLine.cells) == 0 { newLine.Append(buffer.terminalState.DefaultCell(true)) } diff --git a/buffer/line.go b/buffer/line.go index 270b26f..3919d44 100644 --- a/buffer/line.go +++ b/buffer/line.go @@ -6,12 +6,14 @@ import ( type Line struct { wrapped bool // whether line was wrapped onto from the previous one + nobreak bool // true if no line break at the beginning of the line cells []Cell } func newLine() Line { return Line{ wrapped: false, + nobreak: false, cells: []Cell{}, } } @@ -45,6 +47,10 @@ func (line *Line) setWrapped(wrapped bool) { line.wrapped = wrapped } +func (line *Line) setNoBreak(nobreak bool) { + line.nobreak = nobreak +} + func (line *Line) String() string { runes := []rune{} for _, cell := range line.cells {