folder filter: only assume regex if filter is ~fmt
This commit is contained in:
parent
1f5293931a
commit
334ca89bea
|
@ -226,7 +226,7 @@ Note that many of these configuration options are written for you, such as
|
||||||
|
|
||||||
*folders*
|
*folders*
|
||||||
Specifies the comma separated list of folders to display in the sidebar.
|
Specifies the comma separated list of folders to display in the sidebar.
|
||||||
Supports regex patterns.
|
Names prefixed with ~ are interpreted as regular expressions.
|
||||||
|
|
||||||
Default: all folders
|
Default: all folders
|
||||||
|
|
||||||
|
|
|
@ -161,12 +161,17 @@ func (dirlist *DirectoryList) Prev() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func folderMatches(folder string, pattern string) bool {
|
func folderMatches(folder string, pattern string) bool {
|
||||||
r, err := regexp.Compile(pattern)
|
if len(pattern) == 0 {
|
||||||
if err != nil {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if pattern[0] == '~' {
|
||||||
return r.Match([]byte(folder))
|
r, err := regexp.Compile(pattern)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return r.Match([]byte(folder))
|
||||||
|
}
|
||||||
|
return pattern == folder
|
||||||
}
|
}
|
||||||
|
|
||||||
// filterDirsByFoldersConfig sets dirlist.dirs to the filtered subset of the
|
// filterDirsByFoldersConfig sets dirlist.dirs to the filtered subset of the
|
||||||
|
|
Loading…
Reference in New Issue