From d46ccfc8054cd57441ba0a2d4c1519fe84dd9f72 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 6 Nov 2020 20:10:15 +0300 Subject: [PATCH] resort directories if ignorecase/ignoredia change Related #320 --- eval.go | 12 ++++++++++++ nav.go | 9 ++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/eval.go b/eval.go index 651ead6..ed8eb15 100644 --- a/eval.go +++ b/eval.go @@ -88,16 +88,28 @@ func (e *setExpr) eval(app *app, args []string) { gOpts.icons = !gOpts.icons case "ignorecase": gOpts.ignorecase = true + app.nav.sort() + app.ui.sort() case "noignorecase": gOpts.ignorecase = false + app.nav.sort() + app.ui.sort() case "ignorecase!": gOpts.ignorecase = !gOpts.ignorecase + app.nav.sort() + app.ui.sort() case "ignoredia": gOpts.ignoredia = true + app.nav.sort() + app.ui.sort() case "noignoredia": gOpts.ignoredia = false + app.nav.sort() + app.ui.sort() case "ignoredia!": gOpts.ignoredia = !gOpts.ignoredia + app.nav.sort() + app.ui.sort() case "incsearch": gOpts.incsearch = true case "noincsearch": diff --git a/nav.go b/nav.go index df5b312..6d9526a 100644 --- a/nav.go +++ b/nav.go @@ -114,6 +114,8 @@ type dir struct { allFiles []*file // all files in directory including hidden ones (same array as files) sortType sortType // sort method and options from last sort hiddenfiles []string // hiddenfiles value from last sort + ignorecase bool // ignorecase value from last sort + ignoredia bool // ignoredia value from last sort noPerm bool // whether lf has no permission to open the directory } @@ -149,6 +151,8 @@ func normalize(s1, s2 string) (string, string) { func (dir *dir) sort() { dir.sortType = gOpts.sortType dir.hiddenfiles = gOpts.hiddenfiles + dir.ignorecase = gOpts.ignorecase + dir.ignoredia = gOpts.ignoredia dir.files = dir.allFiles @@ -342,7 +346,10 @@ func (nav *nav) checkDir(dir *dir) { nd.sort() nav.dirChan <- nd }() - case dir.sortType != gOpts.sortType || !reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles): + case dir.sortType != gOpts.sortType || + !reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) || + dir.ignorecase != gOpts.ignorecase || + dir.ignoredia != gOpts.ignoredia: dir.loading = true go func() { dir.sort()