Skip to content

Commit

Permalink
fix out of bounds error when apps seek ahead of next row
Browse files Browse the repository at this point in the history
fixes fyne-io#1
  • Loading branch information
andydotxyz committed May 6, 2020
1 parent 2e95afc commit 5e5b0f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions output.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (t *Terminal) handleOutput(buf []byte) {
if t.cursorCol >= int(t.config.Columns) || t.cursorRow >= int(t.config.Rows) {
break // TODO handle wrap?
}
if len(t.content.Rows)-1 < int(t.cursorRow) {
for len(t.content.Rows)-1 < t.cursorRow {
t.content.Rows = append(t.content.Rows, widget.TextGridRow{})
}

Expand All @@ -91,12 +91,12 @@ func (t *Terminal) handleOutput(buf []byte) {

cellStyle := &widget.CustomTextGridStyle{FGColor: currentFG, BGColor: currentBG}

if len(t.content.Rows[t.cursorRow].Cells)-1 < int(t.cursorCol) {
newcell := widget.TextGridCell{
if len(t.content.Rows[t.cursorRow].Cells)-1 < t.cursorCol {
newCell := widget.TextGridCell{
Rune: r,
Style: cellStyle,
}
t.content.Rows[t.cursorRow].Cells = append(t.content.Rows[t.cursorRow].Cells, newcell)
t.content.Rows[t.cursorRow].Cells = append(t.content.Rows[t.cursorRow].Cells, newCell)
} else {
t.content.Rows[t.cursorRow].Cells[t.cursorCol].Rune = r
t.content.Rows[t.cursorRow].Cells[t.cursorCol].Style = cellStyle
Expand Down

0 comments on commit 5e5b0f5

Please sign in to comment.