glob-select implementation (#184)
* glob-select logical implementation * documentation * indentation * indentation * indentation * save * merge glob selects * check if selected before toggling * glob-unselect * identation ... * return early
This commit is contained in:
1 parent
eb8e516cfb
commit
bf39c7c63b
6 files changed
+53
No files matched your search
@@ -794,6 +794,30 @@ func (nav *nav) sel(path string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *nav) globSel(pattern string, invert bool) error {
|
||||
curDir := nav.currDir()
|
||||
anyMatches := false
|
||||
|
||||
for i := 0; i < len(curDir.files); i++ {
|
||||
match, err := filepath.Match(pattern, curDir.files[i].Name())
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("glob-select: %s", err)
|
||||
}
|
||||
if match {
|
||||
anyMatches = true
|
||||
fpath := filepath.Join(curDir.path, curDir.files[i].Name())
|
||||
if _, ok := nav.selections[fpath]; ok == invert {
|
||||
nav.toggleSelection(fpath)
|
||||
}
|
||||
}
|
||||
}
|
||||
if !anyMatches {
|
||||
return fmt.Errorf("glob-select: pattern not found: %s", pattern)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func findMatch(name, pattern string) bool {
|
||||
if gOpts.ignorecase {
|
||||
lpattern := strings.ToLower(pattern)
|
||||
|
||||
Reference in new issue
Block a user