Don't crash on files without an extension

pull/25/head
Wilfred Hughes 2021-07-20 00:10:58 +07:00
parent 27069e0a9e
commit 6bec8b7e2c
2 changed files with 6 additions and 7 deletions

@ -2,7 +2,8 @@
### Parsing
Fixed a crash on parsing non-ASCII source files.
Fixed a crash on parsing non-ASCII source files. Fixed a crash on
files without an extension.
Improved parsing for Rust punctuation.

@ -72,12 +72,10 @@ fn main() {
let syntax_toml = ConfigDir::read_default_toml();
let extension = Path::new(&display_path)
.extension()
.and_then(OsStr::to_str)
.unwrap();
let lang = find_lang(syntax_toml, extension);
let lang = match Path::new(&display_path).extension() {
Some(extension) => find_lang(syntax_toml, &OsStr::to_string_lossy(extension)),
None => None,
};
let terminal_width = match matches.value_of("COLUMNS") {
Some(width) => width.parse::<usize>().unwrap(),