Add HOME directory expansion also for open file command

This commit is contained in:
Francesco Abbate
2020-12-20 00:31:49 +01:00
parent 4401f33c19
commit 9a12d47afd
2 changed files with 15 additions and 16 deletions
+6 -4
View File
@@ -153,16 +153,18 @@ end
function common.home_encode(text)
local n = #HOME
if text:sub(1, n) == HOME and text:sub(n + 1, n + 1):match("[/\\\\]") then
return "~" .. text:sub(n + 1)
if HOME then
local n = #HOME
if text:sub(1, n) == HOME and text:sub(n + 1, n + 1):match("[/\\\\]") then
return "~" .. text:sub(n + 1)
end
end
return text
end
function common.home_expand(text)
return text:gsub("^~", HOME)
return HOME and text:gsub("^~", HOME) or text
end