Add HOME directory expansion also for open file command
This commit is contained in:
parent
4401f33c19
commit
9a12d47afd
|
@ -8,20 +8,15 @@ local LogView = require "core.logview"
|
|||
local fullscreen = false
|
||||
|
||||
local function home_encode_list(paths)
|
||||
if HOME then
|
||||
local t = {}
|
||||
for i = 1, #paths do
|
||||
t[i] = common.home_encode(paths[i])
|
||||
end
|
||||
return t
|
||||
local t = {}
|
||||
for i = 1, #paths do
|
||||
t[i] = common.home_encode(paths[i])
|
||||
end
|
||||
return paths
|
||||
return t
|
||||
end
|
||||
|
||||
local function suggest_directory(text)
|
||||
if HOME then
|
||||
text = common.home_expand(text)
|
||||
end
|
||||
text = common.home_expand(text)
|
||||
return home_encode_list(text == "" and core.recent_projects or common.dir_path_suggest(text))
|
||||
end
|
||||
|
||||
|
@ -110,8 +105,10 @@ command.add(nil, {
|
|||
|
||||
["core:open-file"] = function()
|
||||
core.command_view:enter("Open File", function(text)
|
||||
core.root_view:open_doc(core.open_doc(text))
|
||||
end, common.path_suggest)
|
||||
core.root_view:open_doc(core.open_doc(common.home_expand(text)))
|
||||
end, function (text)
|
||||
return home_encode_list(common.path_suggest(common.home_expand(text)))
|
||||
end)
|
||||
end,
|
||||
|
||||
["core:open-log"] = function()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue