Another small fix for the ANSI regex

This commit is contained in:
sharkdp 2017-05-14 22:06:15 +02:00
parent 75f1404c25
commit b170396fc7
1 changed files with 4 additions and 1 deletions

View File

@ -148,7 +148,7 @@ fn parse_dircolors(path: &Path) -> std::io::Result<ExtensionStyles> {
.unwrap(); .unwrap();
let pattern_ansi = let pattern_ansi =
Regex::new(r"^\.([A-Za-z0-9]+)\s*(?:([0-9][0-9]);)?([0-9][0-9])\b") Regex::new(r"^\.([A-Za-z0-9]+)\s*(?:([0-9]+);)?([0-9][0-9])\b")
.unwrap(); .unwrap();
for line in BufReader::new(file).lines() { for line in BufReader::new(file).lines() {
@ -178,8 +178,11 @@ fn parse_dircolors(path: &Path) -> std::io::Result<ExtensionStyles> {
let style_s = caps.get(2) let style_s = caps.get(2)
.map_or("", |m| m.as_str()); .map_or("", |m| m.as_str());
let style = match style_s { let style = match style_s {
"1" => color.bold(),
"01" => color.bold(), "01" => color.bold(),
"3" => color.italic(),
"03" => color.italic(), "03" => color.italic(),
"4" => color.underline(),
"04" => color.underline(), "04" => color.underline(),
_ => color.normal() _ => color.normal()
}; };