diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-10 14:50:24 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-10 14:50:24 +0900 |
commit | f670f4f076867d6876bcbc832a9b464bbe4f8f68 (patch) | |
tree | b36e1023e2433e1b2ca1b59810287bf9eb3dd1ca /src/terminal.go | |
parent | 6e86fee588bdcd769501ab671fa21a8e8e2de828 (diff) |
Make sure that cy is properly limited
Diffstat (limited to 'src/terminal.go')
-rw-r--r-- | src/terminal.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/terminal.go b/src/terminal.go index fb17ce5b..7039e57c 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -543,8 +543,7 @@ func (t *Terminal) Loop() { } else if me.Double { // Double-click if my >= 2 { - t.cy = my - 2 - if t.listIndex(t.cy) < t.merger.Length() { + if t.vset(my-2) && t.listIndex(t.cy) < t.merger.Length() { req(REQ_CLOSE) } } @@ -554,8 +553,7 @@ func (t *Terminal) Loop() { t.cx = mx } else if my >= 2 { // List - t.cy = t.offset + my - 2 - if t.multi && me.Mod { + if t.vset(t.offset+my-2) && t.multi && me.Mod { toggle() } req(REQ_LIST) @@ -598,11 +596,15 @@ func (t *Terminal) constrain() { func (t *Terminal) vmove(o int) { if t.reverse { - t.cy -= o + t.vset(t.cy - o) } 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 { |