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