Support env flags in shebang (#1224)

imgbot
ath3 3 years ago committed by GitHub
parent 038a6ce22c
commit 70c62530ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -310,8 +310,9 @@ impl Loader {
pub fn language_config_for_shebang(&self, source: &Rope) -> Option<Arc<LanguageConfiguration>> { pub fn language_config_for_shebang(&self, source: &Rope) -> Option<Arc<LanguageConfiguration>> {
let line = Cow::from(source.line(0)); let line = Cow::from(source.line(0));
static SHEBANG_REGEX: Lazy<Regex> = static SHEBANG_REGEX: Lazy<Regex> = Lazy::new(|| {
Lazy::new(|| Regex::new(r"^#!\s*(?:\S*[/\\](?:env\s+)?)?([^\s\.\d]+)").unwrap()); Regex::new(r"^#!\s*(?:\S*[/\\](?:env\s+(?:\-\S+\s+)*)?)?([^\s\.\d]+)").unwrap()
});
let configuration_id = SHEBANG_REGEX let configuration_id = SHEBANG_REGEX
.captures(&line) .captures(&line)
.and_then(|cap| self.language_config_ids_by_shebang.get(&cap[1])); .and_then(|cap| self.language_config_ids_by_shebang.get(&cap[1]));

Loading…
Cancel
Save