1
0
mirror of https://github.com/gdamore/tcell.git synced 2025-04-24 13:48:51 +08:00

views: fix corner case for limitCursor()

If m.width and m.height have not been initialized yet m.x and m.y would
be set to -1. Changing the order fixes that.
This commit is contained in:
Frank Braun 2017-06-16 13:47:18 +00:00 committed by Garrett D'Amore
parent 440aba81dc
commit b87161466d

View File

@ -57,19 +57,20 @@ func (m *linesModel) GetBounds() (int, int) {
}
func (m *linesModel) limitCursor() {
if m.x < 0 {
m.x = 0
}
if m.y < 0 {
m.y = 0
}
if m.x > m.width-1 {
m.x = m.width - 1
}
if m.y > m.height-1 {
m.y = m.height - 1
}
if m.x < 0 {
m.x = 0
}
if m.y < 0 {
m.y = 0
}
}
func (m *linesModel) SetCursor(x, y int) {
m.x = x
m.y = y