From c31b92491fd2f058d8c59b8b1b5fdd5d32edc2f8 Mon Sep 17 00:00:00 2001 From: Joe Lim <50560759+joelim-work@users.noreply.github.com> Date: Sat, 19 Jul 2025 14:35:13 +1000 Subject: [PATCH] Automatically load `dircounts` after enabling it (#2049) --- eval.go | 4 ++++ nav.go | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/eval.go b/eval.go index 755cbb41..7d92318f 100644 --- a/eval.go +++ b/eval.go @@ -68,6 +68,10 @@ func (e *setExpr) eval(app *app, args []string) { err = applyBoolOpt(&gOpts.dircache, e) case "dircounts", "nodircounts", "dircounts!": err = applyBoolOpt(&gOpts.dircounts, e) + if err == nil { + app.nav.renew() + app.ui.loadFile(app, false) + } case "dirfirst", "nodirfirst", "dirfirst!": err = applyBoolOpt(&gOpts.dirfirst, e) if err == nil { diff --git a/nav.go b/nav.go index e8c4867d..a5014340 100644 --- a/nav.go +++ b/nav.go @@ -625,8 +625,16 @@ func (nav *nav) checkDir(dir *dir) { nd := newDir(dir.path) nav.dirChan <- nd }() + case dir.dircounts != getDirCounts(dir.path): + dir.loading = true + go func() { + nd := newDir(dir.path) + nav.dirChan <- nd + }() + // Although toggling dircounts can affect sorting, it is already handled by + // reloading the directory which should sort the files anyway, so it is not + // checked below. case dir.sortby != getSortBy(dir.path) || - dir.dircounts != getDirCounts(dir.path) || dir.dirfirst != getDirFirst(dir.path) || dir.dironly != getDirOnly(dir.path) || dir.hidden != getHidden(dir.path) ||