feat: allow specifying an input captures-path argument

This commit is contained in:
Amaan Qureshi 2023-07-20 04:57:11 -04:00
parent 458b5de0fc
commit 9971e5d5f5
No known key found for this signature in database
GPG key ID: E67890ADC4227273
2 changed files with 32 additions and 6 deletions

View file

@ -390,12 +390,16 @@ impl HighlightConfiguration {
// Return the list of this configuration's capture names that are neither present in the
// list of predefined 'canonical' names nor start with an underscore (denoting 'private' captures
// used as part of capture internals).
pub fn nonconformant_capture_names(&self) -> Vec<&String> {
return self
.names()
pub fn nonconformant_capture_names(&self, capture_names: &HashSet<&str>) -> Vec<&String> {
let capture_names = if capture_names.is_empty() {
&*STANDARD_CAPTURE_NAMES
} else {
&capture_names
};
self.names()
.iter()
.filter(|&n| !(n.starts_with('_') || STANDARD_CAPTURE_NAMES.contains(n.as_str())))
.collect();
.filter(|&n| !(n.starts_with('_') || capture_names.contains(n.as_str())))
.collect()
}
}