mirror of
https://github.com/sharkdp/bat
synced 2024-11-18 15:26:16 +00:00
Incorporating feedback
This commit is contained in:
parent
48b4a6a906
commit
9e2ea5fdd4
@ -63,15 +63,15 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_syntax_mapping_to_paths(
|
fn get_syntax_mapping_to_paths(
|
||||||
mappings: Vec<(GlobMatcher, MappingTarget)>,
|
mappings: &[(GlobMatcher, MappingTarget)],
|
||||||
) -> HashMap<String, Vec<String>> {
|
) -> HashMap<String, Vec<String>> {
|
||||||
let mut map = HashMap::new();
|
let mut map: HashMap<String, Vec<String>> = HashMap::new();
|
||||||
for mapping in mappings {
|
for mapping in mappings {
|
||||||
match mapping.1 {
|
match mapping {
|
||||||
MappingTarget::MapToUnknown => {}
|
(_, MappingTarget::MapToUnknown) => {}
|
||||||
MappingTarget::MapTo(s) => {
|
(matcher, MappingTarget::MapTo(s)) => {
|
||||||
let globs = map.entry(s.into()).or_insert(Vec::new());
|
let globs = map.entry((*s).into()).or_insert(Vec::new());
|
||||||
globs.push(mapping.0.glob().glob().into());
|
globs.push(matcher.glob().glob().into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,14 +88,15 @@ pub fn list_languages(config: &Config) -> Result<()> {
|
|||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
languages.sort_by_key(|lang| lang.name.to_uppercase());
|
languages.sort_by_key(|lang| lang.name.to_uppercase());
|
||||||
|
|
||||||
let configured_languages =
|
let configured_languages = get_syntax_mapping_to_paths(config.syntax_mapping.mappings());
|
||||||
get_syntax_mapping_to_paths(config.syntax_mapping.mappings().clone());
|
|
||||||
|
|
||||||
for lang in languages.iter_mut() {
|
for lang in languages.iter_mut() {
|
||||||
if configured_languages.contains_key(&lang.name) {
|
match configured_languages.get(&lang.name) {
|
||||||
let additional_paths = configured_languages.get(&lang.name).unwrap();
|
Some(additional_paths) => {
|
||||||
lang.file_extensions
|
lang.file_extensions
|
||||||
.extend(additional_paths.iter().cloned());
|
.extend(additional_paths.iter().cloned());
|
||||||
|
}
|
||||||
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user