Fix memory leaking (#156)

This commit is contained in:
nikitar020 2019-01-17 12:17:51 +00:00 committed by Liam Galvin
parent 43072eb024
commit 6f11a23e6a
1 changed files with 3 additions and 1 deletions

View File

@ -587,7 +587,8 @@ func (buffer *Buffer) Index() {
buffer.lines = append(buffer.lines, newLine())
maxLines := buffer.getMaxLines()
if uint64(len(buffer.lines)) > maxLines {
buffer.lines = buffer.lines[ uint64(len(buffer.lines)) - maxLines : ]
copy(buffer.lines, buffer.lines[ uint64(len(buffer.lines)) - maxLines:])
buffer.lines = buffer.lines[:maxLines]
}
} else {
buffer.cursorY++
@ -968,6 +969,7 @@ func (buffer *Buffer) ResizeView(width uint16, height uint16) {
if i+1 < len(buffer.lines) {
nextLine := &buffer.lines[i+1]
if nextLine.wrapped {
nextLine.cells = append(sillyCells, nextLine.cells...)
continue
}