parent
24489924b7
commit
c2f2d54cee
4
doc.go
4
doc.go
@ -552,11 +552,11 @@ This option does not have any effect on windows.
|
||||
|
||||
ignorecase bool (default on)
|
||||
|
||||
Ignore case in search patterns.
|
||||
Ignore case in sorting and search patterns.
|
||||
|
||||
ignoredia bool (default off)
|
||||
|
||||
Ignore diacritics in search patterns.
|
||||
Ignore diacritics in sorting and search patterns.
|
||||
|
||||
incsearch bool (default off)
|
||||
|
||||
|
12
docstring.go
12
docstring.go
@ -428,13 +428,13 @@ Autocomplete the current word.
|
||||
|
||||
cmd-menu-complete
|
||||
|
||||
Autocomplete the current word, then you can press the binded key/s
|
||||
again to cycle completition options.
|
||||
Autocomplete the current word, then you can press the binded key/s again to
|
||||
cycle completition options.
|
||||
|
||||
cmd-menu-complete-back
|
||||
|
||||
Autocomplete the current word, then you can press the binded key/s
|
||||
again to cycle completition options backwards.
|
||||
Autocomplete the current word, then you can press the binded key/s again to
|
||||
cycle completition options backwards.
|
||||
|
||||
cmd-enter (default '<c-j>' and '<enter>')
|
||||
|
||||
@ -582,11 +582,11 @@ have any effect on windows.
|
||||
|
||||
ignorecase bool (default on)
|
||||
|
||||
Ignore case in search patterns.
|
||||
Ignore case in sorting and search patterns.
|
||||
|
||||
ignoredia bool (default off)
|
||||
|
||||
Ignore diacritics in search patterns.
|
||||
Ignore diacritics in sorting and search patterns.
|
||||
|
||||
incsearch bool (default off)
|
||||
|
||||
|
18
lf.1
18
lf.1
@ -83,6 +83,8 @@ The following command line commands are provided by lf:
|
||||
.EX
|
||||
cmd-escape (default '<esc>')
|
||||
cmd-complete (default '<tab>')
|
||||
cmd-menu-complete
|
||||
cmd-menu-complete-back
|
||||
cmd-enter (default '<c-j>' and '<enter>')
|
||||
cmd-interrupt (default '<c-c>')
|
||||
cmd-history-next (default '<c-n>')
|
||||
@ -491,6 +493,18 @@ Quit command line mode and return to normal mode.
|
||||
.PP
|
||||
Autocomplete the current word.
|
||||
.PP
|
||||
.EX
|
||||
cmd-menu-complete
|
||||
.EE
|
||||
.PP
|
||||
Autocomplete the current word, then you can press the binded key/s again to cycle completition options.
|
||||
.PP
|
||||
.EX
|
||||
cmd-menu-complete-back
|
||||
.EE
|
||||
.PP
|
||||
Autocomplete the current word, then you can press the binded key/s again to cycle completition options backwards.
|
||||
.PP
|
||||
.EX
|
||||
cmd-enter (default '<c-j>' and '<enter>')
|
||||
.EE
|
||||
@ -656,13 +670,13 @@ Sets 'IFS' variable in shell commands. It works by adding the assignment to the
|
||||
ignorecase bool (default on)
|
||||
.EE
|
||||
.PP
|
||||
Ignore case in search patterns.
|
||||
Ignore case in sorting and search patterns.
|
||||
.PP
|
||||
.EX
|
||||
ignoredia bool (default off)
|
||||
.EE
|
||||
.PP
|
||||
Ignore diacritics in search patterns.
|
||||
Ignore diacritics in sorting and search patterns.
|
||||
.PP
|
||||
.EX
|
||||
incsearch bool (default off)
|
||||
|
35
nav.go
35
nav.go
@ -134,6 +134,18 @@ func newDir(path string) *dir {
|
||||
}
|
||||
}
|
||||
|
||||
func normalize(s1, s2 string) (string, string) {
|
||||
if gOpts.ignorecase {
|
||||
s1 = strings.ToLower(s1)
|
||||
s2 = strings.ToLower(s2)
|
||||
}
|
||||
if gOpts.ignoredia {
|
||||
s1 = removeDiacritics(s1)
|
||||
s2 = removeDiacritics(s2)
|
||||
}
|
||||
return s1, s2
|
||||
}
|
||||
|
||||
func (dir *dir) sort() {
|
||||
dir.sortType = gOpts.sortType
|
||||
dir.hiddenfiles = gOpts.hiddenfiles
|
||||
@ -143,11 +155,13 @@ func (dir *dir) sort() {
|
||||
switch gOpts.sortType.method {
|
||||
case naturalSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
return naturalLess(strings.ToLower(dir.files[i].Name()), strings.ToLower(dir.files[j].Name()))
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name())
|
||||
return naturalLess(s1, s2)
|
||||
})
|
||||
case nameSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
return strings.ToLower(dir.files[i].Name()) < strings.ToLower(dir.files[j].Name())
|
||||
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name())
|
||||
return s1 < s2
|
||||
})
|
||||
case sizeSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
@ -167,23 +181,22 @@ func (dir *dir) sort() {
|
||||
})
|
||||
case extSort:
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
leftExt := strings.ToLower(dir.files[i].ext)
|
||||
rightExt := strings.ToLower(dir.files[j].ext)
|
||||
ext1, ext2 := normalize(dir.files[i].ext, dir.files[j].ext)
|
||||
|
||||
// if the extension could not be determined (directories, files without)
|
||||
// use a zero byte so that these files can be ranked higher
|
||||
if leftExt == "" {
|
||||
leftExt = "\x00"
|
||||
if ext1 == "" {
|
||||
ext1 = "\x00"
|
||||
}
|
||||
if rightExt == "" {
|
||||
rightExt = "\x00"
|
||||
if ext2 == "" {
|
||||
ext2 = "\x00"
|
||||
}
|
||||
|
||||
name1, name2 := normalize(dir.files[i].Name(), dir.files[j].Name())
|
||||
|
||||
// in order to also have natural sorting with the filenames
|
||||
// combine the name with the ext but have the ext at the front
|
||||
left := leftExt + strings.ToLower(dir.files[i].Name())
|
||||
right := rightExt + strings.ToLower(dir.files[j].Name())
|
||||
return left < right
|
||||
return (ext1 + name1) < (ext2 + name2)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user