Use tilde expansion when running save-as command
This commit is contained in:
parent
1decf67b64
commit
6369a7f760
|
@ -7,17 +7,9 @@ local LogView = require "core.logview"
|
|||
|
||||
local fullscreen = false
|
||||
|
||||
local function home_encode_list(paths)
|
||||
local t = {}
|
||||
for i = 1, #paths do
|
||||
t[i] = common.home_encode(paths[i])
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local function suggest_directory(text)
|
||||
text = common.home_expand(text)
|
||||
return home_encode_list(text == "" and core.recent_projects or common.dir_path_suggest(text))
|
||||
return common.home_encode_list(text == "" and core.recent_projects or common.dir_path_suggest(text))
|
||||
end
|
||||
|
||||
command.add(nil, {
|
||||
|
@ -95,7 +87,7 @@ command.add(nil, {
|
|||
core.command_view:enter("Open File", function(text)
|
||||
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)))
|
||||
return common.home_encode_list(common.path_suggest(common.home_expand(text)))
|
||||
end)
|
||||
end,
|
||||
|
||||
|
@ -178,7 +170,7 @@ command.add(nil, {
|
|||
end
|
||||
end, function(text)
|
||||
text = common.home_expand(text)
|
||||
return home_encode_list(common.dir_list_suggest(text, dir_list))
|
||||
return common.home_encode_list(common.dir_list_suggest(text, dir_list))
|
||||
end)
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -301,8 +301,10 @@ local commands = {
|
|||
core.command_view:set_text(doc().filename)
|
||||
end
|
||||
core.command_view:enter("Save As", function(filename)
|
||||
save(filename)
|
||||
end, common.path_suggest)
|
||||
save(common.home_expand(filename))
|
||||
end, function (text)
|
||||
return common.home_encode_list(common.path_suggest(common.home_expand(text)))
|
||||
end)
|
||||
end,
|
||||
|
||||
["doc:save"] = function()
|
||||
|
|
|
@ -214,6 +214,15 @@ function common.home_encode(text)
|
|||
end
|
||||
|
||||
|
||||
function common.home_encode_list(paths)
|
||||
local t = {}
|
||||
for i = 1, #paths do
|
||||
t[i] = common.home_encode(paths[i])
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
|
||||
function common.home_expand(text)
|
||||
return HOME and text:gsub("^~", HOME) or text
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue