diff options
author | Canop <cano.petrole@gmail.com> | 2019-02-11 18:19:18 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-02-11 18:19:18 +0100 |
commit | 84bfc6b77846fd643f878c337fee23bb0b6153fc (patch) | |
tree | 9970107a79c9eb8f003579cae07b5c4bf73f7d93 /src/git_ignore.rs | |
parent | e87b5f654a5949eba90dc5aecc911ecd9105a671 (diff) |
handle errors on a few cases of non suitable root
* initial path not a file: display an error and exit
* initial path not a directory: open the parent instead
* directory removed between display and focus: display an error in
status
Diffstat (limited to 'src/git_ignore.rs')
-rw-r--r-- | src/git_ignore.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/git_ignore.rs b/src/git_ignore.rs index 4c975c0..edfb14e 100644 --- a/src/git_ignore.rs +++ b/src/git_ignore.rs @@ -122,16 +122,13 @@ impl GitIgnoreFilter { if rule.directory && !directory { continue; } - if rule.filename { - if rule.pattern.matches_with(filename, &rule.pattern_options) { - //debug!("rule matches filename {:?} -> ok={}", path, rule.ok); - return rule.ok; - } + let ok = if rule.filename { + rule.pattern.matches_with(filename, &rule.pattern_options) } else { - if rule.pattern.matches_path_with(path, &rule.pattern_options) { - //debug!("rule matches path {:?} -> ok={}", path, rule.ok); - return rule.ok; - } + rule.pattern.matches_path_with(path, &rule.pattern_options) + }; + if ok { + return rule.ok; } } } |