Skip to content

Commit

Permalink
avoid loading redundant previews for top/bottom
Browse files Browse the repository at this point in the history
cc #531
  • Loading branch information
gokcehan committed Jan 18, 2021
1 parent 7481040 commit e031761
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
14 changes: 8 additions & 6 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 10 additions & 2 deletions nav.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e031761

Please sign in to comment.