avoid loading redundant previews for top/bottom

cc #531
This commit is contained in:
Gokcehan 2021-01-19 01:47:09 +03:00
parent 7481040c2d
commit e0317611ef
2 changed files with 18 additions and 8 deletions

14
eval.go
View File

@ -719,16 +719,18 @@ func (e *callExpr) eval(app *app, args []string) {
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
normal(app)
}
app.nav.top()
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
if app.nav.top() {
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
}
case "bottom":
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
normal(app)
}
app.nav.bottom()
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
if app.nav.bottom() {
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
}
case "toggle":
if len(e.args) == 0 {
app.nav.toggle()

12
nav.go
View File

@ -677,18 +677,26 @@ func (nav *nav) open() error {
return nil
}
func (nav *nav) top() {
func (nav *nav) top() bool {
dir := nav.currDir()
old := dir.ind
dir.ind = 0
dir.pos = 0
return old != dir.ind
}
func (nav *nav) bottom() {
func (nav *nav) bottom() bool {
dir := nav.currDir()
old := dir.ind
dir.ind = len(dir.files) - 1
dir.pos = min(dir.ind, nav.height-1)
return old != dir.ind
}
func (nav *nav) toggleSelection(path string) {