1
1
mirror of https://github.com/walles/moar.git synced 2024-11-30 12:42:26 +03:00
moar/m/scrollPosition_test.go

39 lines
919 B
Go
Raw Normal View History

package m
import (
"strings"
"testing"
"github.com/walles/moar/twin"
"gotest.tools/v3/assert"
)
// Repro for: https://github.com/walles/moar/issues/166
func TestCanonicalize1000(t *testing.T) {
pager := Pager{}
pager.screen = twin.NewFakeScreen(100, 60)
pager.reader = NewReaderFromText("test", strings.Repeat("a\n", 2000))
pager.ShowLineNumbers = true
pager.ShowStatusBar = true
pager.scrollPosition = scrollPosition{
internalDontTouch: scrollPositionInternal{
lineNumberOneBased: 941,
deltaScreenLines: 0,
name: "findFirstHit",
canonicalizing: false,
},
}
lastVisiblePosition := scrollPosition{
internalDontTouch: scrollPositionInternal{
lineNumberOneBased: 999,
deltaScreenLines: 0,
name: "Last Visible Position",
},
}
lineNumberOneBased := lastVisiblePosition.lineNumberOneBased(&pager)
assert.Equal(t, lineNumberOneBased, 42)
}