#249 no newlines when copying (#261)

This commit is contained in:
rrrooommmaaa 2019-03-20 12:51:42 +03:00 committed by GitHub
parent 070f29ad13
commit 68953464ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {
@ -704,6 +704,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 {