diff --git a/Cargo.lock b/Cargo.lock index b5d3faebb..1187209be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1134,7 +1134,7 @@ checksum = "53953d2d3a5ad81d9f844a32f14ebb121f50b650cd59d0ee2a07cf13c617efed" [[package]] name = "tokei" -version = "12.0.2" +version = "12.0.3" dependencies = [ "aho-corasick", "clap", diff --git a/Cargo.toml b/Cargo.toml index a17aac7ae..0069984cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ license = "MIT/Apache-2.0" name = "tokei" readme = "README.md" repository = "https://github.com/XAMPPRocky/tokei.git" -version = "12.0.2" +version = "12.0.3" [features] all = ["cbor", "yaml"] diff --git a/src/language/syntax.rs b/src/language/syntax.rs index 6cb4cb6c9..db43b3223 100644 --- a/src/language/syntax.rs +++ b/src/language/syntax.rs @@ -461,8 +461,13 @@ impl SyntaxCounter { LanguageType::from_mime(&String::from_utf8_lossy(m.as_bytes().trim())) }) .unwrap_or(LanguageType::JavaScript); + let script_contents = &lines[start_of_code..end_of_code]; + if script_contents.trim().is_empty() { + return None + } + let stats = language.parse_from_slice( - &lines[start_of_code..end_of_code].trim_first_and_last_line_of_whitespace(), + script_contents.trim_first_and_last_line_of_whitespace(), config, ); Some(FileContext::new(