Unified open and saving style. (#189)

This commit is contained in:
Adam 2021-05-17 03:29:51 -04:00 committed by GitHub
parent 85d0d684de
commit e43f1b9df9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,8 @@ command.add(nil, {
["core:open-file"] = function() ["core:open-file"] = function()
local view = core.active_view local view = core.active_view
if view.doc and view.doc.abs_filename then if view.doc and view.doc.abs_filename then
core.command_view:set_text(common.home_encode(view.doc.abs_filename)) local dirname, filename = view.doc.abs_filename:match("(.*)[/\\](.+)$")
core.command_view:set_text(core.normalize_to_project_dir(dirname) .. PATHSEP)
end end
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)))

View File

@ -299,6 +299,9 @@ local commands = {
["doc:save-as"] = function() ["doc:save-as"] = function()
if doc().filename then if doc().filename then
core.command_view:set_text(doc().filename) core.command_view:set_text(doc().filename)
elseif core.last_active_view then
local dirname, filename = core.last_active_view.doc.abs_filename:match("(.*)[/\\](.+)$")
core.command_view:set_text(core.normalize_to_project_dir(dirname) .. PATHSEP)
end end
core.command_view:enter("Save As", function(filename) core.command_view:enter("Save As", function(filename)
save(common.home_expand(filename)) save(common.home_expand(filename))