using rust builtin extension function for %{ext}

This commit is contained in:
Théo Daron 2024-08-02 23:00:47 +02:00
parent b5cae57b1e
commit e774706440

View File

@ -74,15 +74,12 @@ pub fn expand_variable_in_string<'a>(&self, input: &'a str) -> anyhow::Result<Co
+ 1)
.to_string(),
"lang" => doc.language_name().unwrap_or("text").to_string(),
"ext" => match doc.relative_path() {
Some(path) => path
.to_string_lossy()
.split(".")
.last()
.unwrap_or("")
.to_string(),
_ => "".to_string(),
},
"ext" => doc
.relative_path()
.and_then(|p| {
p.extension()?.to_os_string().into_string().ok()
})
.unwrap_or_default(),
"selection" => doc
.selection(view.id)
.primary()