This commit is contained in:
Clémentine Urquizar 2021-06-15 18:44:56 +02:00
parent 1ef061d92b
commit 9840b5c7fb
No known key found for this signature in database
GPG Key ID: D8E7CC7422E77E1A

View File

@ -235,9 +235,8 @@ fn parse_formatted_options(
}; };
if attr == "*" { if attr == "*" {
let ids = displayed_ids.clone(); for id in displayed_ids {
for id in ids { formatted_options.insert(*id, new_format);
formatted_options.insert(id, new_format);
} }
break; break;
} }
@ -245,43 +244,40 @@ fn parse_formatted_options(
if let Some(id) = fields_ids_map.id(&attr) { if let Some(id) = fields_ids_map.id(&attr) {
formatted_options.insert(id, new_format); formatted_options.insert(id, new_format);
} }
}; }
for attr in attr_to_crop { for attr in attr_to_crop {
let mut attr_name = attr.clone(); let mut attr_name = attr.clone();
let mut attr_len = Some(query_crop_length); let mut attr_len = query_crop_length;
if attr_name.contains(':') { let mut split = attr_name.rsplitn(2, ':');
let mut split = attr_name.rsplit(':'); attr_name = match split.next().zip(split.next()) {
attr_len = match split.next() { Some((len, name)) => {
Some(s) => s.parse::<usize>().ok(), attr_len = len.parse().unwrap_or(query_crop_length);
None => None, name.to_string()
},
None => attr_name,
}; };
attr_name = split.flat_map(|s| s.chars()).collect();
}
if attr_name == "*" { if attr_name == "*" {
let ids = displayed_ids.clone(); for id in displayed_ids {
for id in ids { formatted_options
let mut highlight = false; .entry(*id)
if let Some(f) = formatted_options.get(&id) { .and_modify(|f| f.crop = Some(attr_len))
highlight = f.highlight; .or_insert(FormatOptions {
} highlight: false,
formatted_options.insert(id, FormatOptions { crop: Some(attr_len),
highlight,
crop: attr_len,
}); });
} }
} }
if let Some(id) = fields_ids_map.id(&attr_name) { if let Some(id) = fields_ids_map.id(&attr_name) {
let mut highlight = false; formatted_options
if let Some(f) = formatted_options.get(&id) { .entry(id)
highlight = f.highlight; .and_modify(|f| f.crop = Some(attr_len))
} .or_insert(FormatOptions {
formatted_options.insert(id, FormatOptions { highlight: false,
highlight, crop: Some(attr_len),
crop: attr_len,
}); });
} }
} }