mirror of https://github.com/liamg/aminal.git
Fix newline at end of buffer issue (#122)
* Fix newline at end of buffer issue * Fix newline at end of buffer issue
This commit is contained in:
parent
d4c684c9b5
commit
4b97358eb0
|
@ -719,6 +719,14 @@ func (buffer *Buffer) NewLine() {
|
||||||
|
|
||||||
buffer.cursorX = 0
|
buffer.cursorX = 0
|
||||||
buffer.Index()
|
buffer.Index()
|
||||||
|
|
||||||
|
for {
|
||||||
|
line := buffer.getCurrentLine()
|
||||||
|
if !line.wrapped {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
buffer.Index()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (buffer *Buffer) MovePosition(x int16, y int16) {
|
func (buffer *Buffer) MovePosition(x int16, y int16) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ hell xxx good
|
||||||
for _, l := range lines {
|
for _, l := range lines {
|
||||||
strs = append(strs, l.String())
|
strs = append(strs, l.String())
|
||||||
}
|
}
|
||||||
require.Equal(t, strings.TrimSpace(expected), strings.Join(strs, "\n"))
|
require.Equal(t, strings.TrimSpace(expected), strings.TrimSpace(strings.Join(strs, "\n")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOffsets(t *testing.T) {
|
func TestOffsets(t *testing.T) {
|
||||||
|
@ -133,7 +133,7 @@ func TestWritingNewLineAsFirstRuneOnWrappedLine(t *testing.T) {
|
||||||
assert.Equal(t, uint16(0), b.cursorX)
|
assert.Equal(t, uint16(0), b.cursorX)
|
||||||
assert.Equal(t, uint16(2), b.cursorY)
|
assert.Equal(t, uint16(2), b.cursorY)
|
||||||
|
|
||||||
require.Equal(t, 2, len(b.lines))
|
require.Equal(t, 3, len(b.lines))
|
||||||
assert.Equal(t, "abc", b.lines[0].String())
|
assert.Equal(t, "abc", b.lines[0].String())
|
||||||
assert.Equal(t, "def", b.lines[1].String())
|
assert.Equal(t, "def", b.lines[1].String())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue