diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua index a3fd948c..725d3b02 100644 --- a/data/core/commands/core.lua +++ b/data/core/commands/core.lua @@ -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, }) diff --git a/data/core/commands/doc.lua b/data/core/commands/doc.lua index 3d1cd7b5..ad590f19 100644 --- a/data/core/commands/doc.lua +++ b/data/core/commands/doc.lua @@ -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() diff --git a/data/core/common.lua b/data/core/common.lua index 6918a2b5..452f4a67 100644 --- a/data/core/common.lua +++ b/data/core/common.lua @@ -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