Do not "--cycle" on page-up/page-down

Close #928
This commit is contained in:
Junegunn Choi 2017-05-24 02:43:39 +09:00
parent e1e3339770
commit f5746002fd
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -1591,20 +1591,20 @@ func (t *Terminal) Loop() {
case actToggleDown: case actToggleDown:
if t.multi && t.merger.Length() > 0 { if t.multi && t.merger.Length() > 0 {
toggle() toggle()
t.vmove(-1) t.vmove(-1, true)
req(reqList) req(reqList)
} }
case actToggleUp: case actToggleUp:
if t.multi && t.merger.Length() > 0 { if t.multi && t.merger.Length() > 0 {
toggle() toggle()
t.vmove(1) t.vmove(1, true)
req(reqList) req(reqList)
} }
case actDown: case actDown:
t.vmove(-1) t.vmove(-1, true)
req(reqList) req(reqList)
case actUp: case actUp:
t.vmove(1) t.vmove(1, true)
req(reqList) req(reqList)
case actAccept: case actAccept:
req(reqClose) req(reqClose)
@ -1632,16 +1632,16 @@ func (t *Terminal) Loop() {
t.input = append(append(t.input[:t.cx], t.yanked...), suffix...) t.input = append(append(t.input[:t.cx], t.yanked...), suffix...)
t.cx += len(t.yanked) t.cx += len(t.yanked)
case actPageUp: case actPageUp:
t.vmove(t.maxItems() - 1) t.vmove(t.maxItems()-1, false)
req(reqList) req(reqList)
case actPageDown: case actPageDown:
t.vmove(-(t.maxItems() - 1)) t.vmove(-(t.maxItems() - 1), false)
req(reqList) req(reqList)
case actHalfPageUp: case actHalfPageUp:
t.vmove(t.maxItems() / 2) t.vmove(t.maxItems()/2, false)
req(reqList) req(reqList)
case actHalfPageDown: case actHalfPageDown:
t.vmove(-(t.maxItems() / 2)) t.vmove(-(t.maxItems() / 2), false)
req(reqList) req(reqList)
case actJump: case actJump:
t.jumping = jumpEnabled t.jumping = jumpEnabled
@ -1699,7 +1699,7 @@ func (t *Terminal) Loop() {
if t.multi && me.Mod { if t.multi && me.Mod {
toggle() toggle()
} }
t.vmove(me.S) t.vmove(me.S, true)
req(reqList) req(reqList)
} else if t.hasPreviewWindow() && t.pwindow.Enclose(my, mx) { } else if t.hasPreviewWindow() && t.pwindow.Enclose(my, mx) {
scrollPreview(-me.S) scrollPreview(-me.S)
@ -1796,12 +1796,12 @@ func (t *Terminal) constrain() {
t.offset = util.Max(0, t.offset) t.offset = util.Max(0, t.offset)
} }
func (t *Terminal) vmove(o int) { func (t *Terminal) vmove(o int, allowCycle bool) {
if t.reverse { if t.reverse {
o *= -1 o *= -1
} }
dest := t.cy + o dest := t.cy + o
if t.cycle { if t.cycle && allowCycle {
max := t.merger.Length() - 1 max := t.merger.Length() - 1
if dest > max { if dest > max {
if t.cy == max { if t.cy == max {