fix order of color/icon matches

cc #543
This commit is contained in:
Gokcehan committed 2021-01-03 01:02:40 +03:00
1 parent 1e94f4533e
commit bfa527fcea
5 files changed
+98 -59

No files matched your search

+16 -18
View File
@@ -233,22 +233,6 @@ func (sm styleMap) get(f *file) tcell.Style {
}
}
if val, ok := sm[f.Name()]; ok {
return val
}
if val, ok := sm[f.Name()]; ok {
return val
}
if val, ok := sm[filepath.Base(f.Name())+".*"]; ok {
return val
}
if val, ok := sm["*"+f.ext]; ok {
return val
}
var key string
switch {
@@ -278,13 +262,27 @@ func (sm styleMap) get(f *file) tcell.Style {
key = "sg"
case f.Mode()&0111 != 0:
key = "ex"
default:
key = "fi"
}
if val, ok := sm[key]; ok {
return val
}
if val, ok := sm[f.Name()]; ok {
return val
}
if val, ok := sm[filepath.Base(f.Name())+".*"]; ok {
return val
}
if val, ok := sm["*"+f.ext]; ok {
return val
}
if val, ok := sm["fi"]; ok {
return val
}
return tcell.StyleDefault
}
+21 -9
View File
@@ -1241,19 +1241,31 @@ The full order of matchings from most specific to least are as follows:
1. Full Path (e.g. '~/.config/lf/lfrc')
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
3. File Name (e.g. '.git')
4. Base Name (e.g. 'README.*')
5. Extension (e.g. '*.txt')
6. File Type (e.g. 'ln')
3. File Type (e.g. 'ln') (except 'fi')
4. File Name (e.g. '.git')
5. Base Name (e.g. 'README.*')
6. Extension (e.g. '*.txt')
7. Default (i.e. 'fi')
For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used:
1. '/path/to/README.txt'
2. 'README.txt/' (skipped since the file is not a directory)
3. 'README.txt'
4. 'README.*'
5. '*.txt'
6. 'fi'
2. (skipped since the file is not a directory)
3. (skipped since the file is of type 'fi')
4. 'README.txt'
5. 'README.*'
6. '*.txt'
7. 'fi'
Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used:
1. '/path/to/example.d'
2. 'example.d/'
3. 'di'
4. 'example.d'
5. 'example.*'
6. '*.d'
7. 'fi'
Note that glob-like patterns do not actually perform glob matching due to performance reasons.
+22 -9
View File
@@ -1400,20 +1400,33 @@ follows:
1. Full Path (e.g. '~/.config/lf/lfrc')
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
3. File Name (e.g. '.git')
4. Base Name (e.g. 'README.*')
5. Extension (e.g. '*.txt')
6. File Type (e.g. 'ln')
3. File Type (e.g. 'ln') (except 'fi')
4. File Name (e.g. '.git')
5. Base Name (e.g. 'README.*')
6. Extension (e.g. '*.txt')
7. Default (i.e. 'fi')
For example, given a regular text file '/path/to/README.txt', the following
entries are checked in the configuration and the first one to match is used:
1. '/path/to/README.txt'
2. 'README.txt/' (skipped since the file is not a directory)
3. 'README.txt'
4. 'README.*'
5. '*.txt'
6. 'fi'
2. (skipped since the file is not a directory)
3. (skipped since the file is of type 'fi')
4. 'README.txt'
5. 'README.*'
6. '*.txt'
7. 'fi'
Given a regular directory '/path/to/example.d', the following entries are
checked in the configuration and the first one to match is used:
1. '/path/to/example.d'
2. 'example.d/'
3. 'di'
4. 'example.d'
5. 'example.*'
6. '*.d'
7. 'fi'
Note that glob-like patterns do not actually perform glob matching due to
performance reasons.
+16 -14
View File
@@ -74,18 +74,6 @@ func (im iconMap) get(f *file) string {
}
}
if val, ok := im[f.Name()]; ok {
return val
}
if val, ok := im[filepath.Base(f.Name())+".*"]; ok {
return val
}
if val, ok := im["*"+f.ext]; ok {
return val
}
var key string
switch {
@@ -115,13 +103,27 @@ func (im iconMap) get(f *file) string {
key = "sg"
case f.Mode()&0111 != 0:
key = "ex"
default:
key = "fi"
}
if val, ok := im[key]; ok {
return val
}
if val, ok := im[f.Name()]; ok {
return val
}
if val, ok := im[filepath.Base(f.Name())+".*"]; ok {
return val
}
if val, ok := im["*"+f.ext]; ok {
return val
}
if val, ok := im["fi"]; ok {
return val
}
return " "
}
+23 -9
View File
@@ -1341,21 +1341,35 @@ Note that, lf first tries matching file names and then falls back to file types.
.EX
1. Full Path (e.g. '~/.config/lf/lfrc')
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
3. File Name (e.g. '.git')
4. Base Name (e.g. 'README.*')
5. Extension (e.g. '*.txt')
6. File Type (e.g. 'ln')
3. File Type (e.g. 'ln') (except 'fi')
4. File Name (e.g. '.git')
5. Base Name (e.g. 'README.*')
6. Extension (e.g. '*.txt')
7. Default (i.e. 'fi')
.EE
.PP
For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used:
.PP
.EX
1. '/path/to/README.txt'
2. 'README.txt/' (skipped since the file is not a directory)
3. 'README.txt'
4. 'README.*'
5. '*.txt'
6. 'fi'
2. (skipped since the file is not a directory)
3. (skipped since the file is of type 'fi')
4. 'README.txt'
5. 'README.*'
6. '*.txt'
7. 'fi'
.EE
.PP
Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used:
.PP
.EX
1. '/path/to/example.d'
2. 'example.d/'
3. 'di'
4. 'example.d'
5. 'example.*'
6. '*.d'
7. 'fi'
.EE
.PP
Note that glob-like patterns do not actually perform glob matching due to performance reasons.