resort directories if ignorecase/ignoredia change

Related #320
This commit is contained in:
Gokcehan 2020-11-06 20:10:15 +03:00
parent e8f115848f
commit d46ccfc805
2 changed files with 20 additions and 1 deletions

12
eval.go
View File

@ -88,16 +88,28 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.icons = !gOpts.icons gOpts.icons = !gOpts.icons
case "ignorecase": case "ignorecase":
gOpts.ignorecase = true gOpts.ignorecase = true
app.nav.sort()
app.ui.sort()
case "noignorecase": case "noignorecase":
gOpts.ignorecase = false gOpts.ignorecase = false
app.nav.sort()
app.ui.sort()
case "ignorecase!": case "ignorecase!":
gOpts.ignorecase = !gOpts.ignorecase gOpts.ignorecase = !gOpts.ignorecase
app.nav.sort()
app.ui.sort()
case "ignoredia": case "ignoredia":
gOpts.ignoredia = true gOpts.ignoredia = true
app.nav.sort()
app.ui.sort()
case "noignoredia": case "noignoredia":
gOpts.ignoredia = false gOpts.ignoredia = false
app.nav.sort()
app.ui.sort()
case "ignoredia!": case "ignoredia!":
gOpts.ignoredia = !gOpts.ignoredia gOpts.ignoredia = !gOpts.ignoredia
app.nav.sort()
app.ui.sort()
case "incsearch": case "incsearch":
gOpts.incsearch = true gOpts.incsearch = true
case "noincsearch": case "noincsearch":

9
nav.go
View File

@ -114,6 +114,8 @@ type dir struct {
allFiles []*file // all files in directory including hidden ones (same array as files) allFiles []*file // all files in directory including hidden ones (same array as files)
sortType sortType // sort method and options from last sort sortType sortType // sort method and options from last sort
hiddenfiles []string // hiddenfiles value 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 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() { func (dir *dir) sort() {
dir.sortType = gOpts.sortType dir.sortType = gOpts.sortType
dir.hiddenfiles = gOpts.hiddenfiles dir.hiddenfiles = gOpts.hiddenfiles
dir.ignorecase = gOpts.ignorecase
dir.ignoredia = gOpts.ignoredia
dir.files = dir.allFiles dir.files = dir.allFiles
@ -342,7 +346,10 @@ func (nav *nav) checkDir(dir *dir) {
nd.sort() nd.sort()
nav.dirChan <- nd 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 dir.loading = true
go func() { go func() {
dir.sort() dir.sort()