#249 no newlines when copying

This commit is contained in:
Roman Shevchenko 2019-03-14 11:07:11 +03:00
parent 4710948cd1
commit 9683ac8c02
2 changed files with 8 additions and 1 deletions

View File

@ -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))
}

View File

@ -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 {