Ignore crate: is it expected that WalkBuilder#types
overrides hidden
default?
#1699
-
Hello 😄 , I have code like this using v0.4.16 of the ignore crate: let matcher = TypesBuilder::new().add_defaults().select("markdown").build().unwrap();
for entry in WalkBuilder::new("./").types(matcher).build() {
# stuff happens...
} My expectation was that this wouldn't match hidden markdown files (e.g. something like What I think is going on is that the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, it's correct. The intent here is that you've explicitly given a type you want to search, and that should generally override more general default behavior. If you want to search non-hidden markdown files, you should be able to filter out hidden files pretty easily. Or you could add an override glob that does it, e.g., Technically, this is somewhat covered by the rule precedence in the docs, although it can be a bit hard to interpret. Specifically, the third rule states:
Now, a "type" matcher isn't explicitly mentioned in rules 1 or 2, but I think it comes after rule 1 but before rule 2. And then the fifth rule says:
Which is basically saying, "unless something else has matched it, as a last ditch attempt to filter stuff out, ignore it if it's hidden." Overall that means that any kind of explicit whitelist rule will override the hidden filtering. |
Beta Was this translation helpful? Give feedback.
Yes, it's correct. The intent here is that you've explicitly given a type you want to search, and that should generally override more general default behavior. If you want to search non-hidden markdown files, you should be able to filter out hidden files pretty easily. Or you could add an override glob that does it, e.g.,
![!.]*
or something like that.Technically, this is somewhat covered by the rule precedence in the docs, although it can be a bit hard to interpret.
Specifically, the third rule states: