From 6b8e9f3a7450bf76fd8223ee4b25cfd082f7ed57 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Fri, 5 May 2023 00:41:22 +1000 Subject: [PATCH 1/2] Prevent scrolling to bottom when selecting files --- nav.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nav.go b/nav.go index 1f205207..8caaa169 100644 --- a/nav.go +++ b/nav.go @@ -486,7 +486,9 @@ func (nav *nav) getDirs(wd string) { for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) { dir := nav.loadDir(curr) - dir.sel(base, nav.height) + if base != "" { + dir.sel(base, nav.height) + } dirs = append(dirs, dir) } @@ -1546,7 +1548,12 @@ func (nav *nav) sel(path string) error { last.files = append(last.files, &file{FileInfo: lstat}) } - last.sel(base, nav.height) + for i, f := range last.files { + if f.Name() == base { + nav.move(i) + break + } + } return nil } From 9f6b131fd63739fae22fe58f22a34c7e2d01589c Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Fri, 5 May 2023 01:00:11 +1000 Subject: [PATCH 2/2] Use nav.currDir() --- nav.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nav.go b/nav.go index 8caaa169..fdc56620 100644 --- a/nav.go +++ b/nav.go @@ -1542,7 +1542,7 @@ func (nav *nav) sel(path string) error { base := filepath.Base(path) - last := nav.dirs[len(nav.dirs)-1] + last := nav.currDir() if last.loading { last.files = append(last.files, &file{FileInfo: lstat})