Make sure that cy is properly limited

This commit is contained in:
Junegunn Choi 2015-01-10 14:50:24 +09:00
parent 6e86fee588
commit f670f4f076

View File

@ -543,8 +543,7 @@ func (t *Terminal) Loop() {
} else if me.Double { } else if me.Double {
// Double-click // Double-click
if my >= 2 { if my >= 2 {
t.cy = my - 2 if t.vset(my-2) && t.listIndex(t.cy) < t.merger.Length() {
if t.listIndex(t.cy) < t.merger.Length() {
req(REQ_CLOSE) req(REQ_CLOSE)
} }
} }
@ -554,8 +553,7 @@ func (t *Terminal) Loop() {
t.cx = mx t.cx = mx
} else if my >= 2 { } else if my >= 2 {
// List // List
t.cy = t.offset + my - 2 if t.vset(t.offset+my-2) && t.multi && me.Mod {
if t.multi && me.Mod {
toggle() toggle()
} }
req(REQ_LIST) req(REQ_LIST)
@ -598,11 +596,15 @@ func (t *Terminal) constrain() {
func (t *Terminal) vmove(o int) { func (t *Terminal) vmove(o int) {
if t.reverse { if t.reverse {
t.cy -= o t.vset(t.cy - o)
} else { } else {
t.cy += o t.vset(t.cy + o)
} }
t.cy = Max(0, Min(t.cy, t.merger.Length()-1)) }
func (t *Terminal) vset(o int) bool {
t.cy = Max(0, Min(o, t.merger.Length()-1))
return t.cy == o
} }
func maxItems() int { func maxItems() int {