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 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)
|
local function suggest_directory(text)
|
||||||
text = common.home_expand(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
|
end
|
||||||
|
|
||||||
command.add(nil, {
|
command.add(nil, {
|
||||||
|
@ -95,7 +87,7 @@ command.add(nil, {
|
||||||
core.command_view:enter("Open File", function(text)
|
core.command_view:enter("Open File", function(text)
|
||||||
core.root_view:open_doc(core.open_doc(common.home_expand(text)))
|
core.root_view:open_doc(core.open_doc(common.home_expand(text)))
|
||||||
end, function (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)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
@ -178,7 +170,7 @@ command.add(nil, {
|
||||||
end
|
end
|
||||||
end, function(text)
|
end, function(text)
|
||||||
text = common.home_expand(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)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
|
@ -301,8 +301,10 @@ local commands = {
|
||||||
core.command_view:set_text(doc().filename)
|
core.command_view:set_text(doc().filename)
|
||||||
end
|
end
|
||||||
core.command_view:enter("Save As", function(filename)
|
core.command_view:enter("Save As", function(filename)
|
||||||
save(filename)
|
save(common.home_expand(filename))
|
||||||
end, common.path_suggest)
|
end, function (text)
|
||||||
|
return common.home_encode_list(common.path_suggest(common.home_expand(text)))
|
||||||
|
end)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["doc:save"] = function()
|
["doc:save"] = function()
|
||||||
|
|
|
@ -214,6 +214,15 @@ function common.home_encode(text)
|
||||||
end
|
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)
|
function common.home_expand(text)
|
||||||
return HOME and text:gsub("^~", HOME) or text
|
return HOME and text:gsub("^~", HOME) or text
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue