diff options
author | E.L.K <some.any.key@gmail.com> | 2021-01-03 22:20:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-04 04:20:31 +0900 |
commit | eaa0c52b457fc7a98e1ca8d5a33aad9397b18662 (patch) | |
tree | b4a77bc8101f1bb1038715ba56a79c5c1840a069 /src | |
parent | 82791f7efccde5b30da0b4d44f10d214ae5c0c0d (diff) |
Fix selection changed on terminal resize (#2306)
Diffstat (limited to 'src')
-rw-r--r-- | src/terminal.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/terminal.go b/src/terminal.go index e7e98827..5d78c6b9 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -2632,18 +2632,16 @@ func (t *Terminal) Loop() { } func (t *Terminal) constrain() { + // count of items to display allowed by filtering count := t.merger.Length() + // count of lines can be displayed height := t.maxItems() - diffpos := t.cy - t.offset t.cy = util.Constrain(t.cy, 0, count-1) - t.offset = util.Constrain(t.offset, t.cy-height+1, t.cy) - // Adjustment - if count-t.offset < height { - t.offset = util.Max(0, count-height) - t.cy = util.Constrain(t.offset+diffpos, 0, count-1) - } - t.offset = util.Max(0, t.offset) + + minOffset := t.cy - height + 1 + maxOffset := util.Max(util.Min(count-height, t.cy), 0) + t.offset = util.Constrain(t.offset, minOffset, maxOffset) } func (t *Terminal) vmove(o int, allowCycle bool) { |