Use the active view's filename when opening a file

This commit is contained in:
adamharrison 2021-04-25 14:58:56 -04:00 committed by GitHub
parent c859498d68
commit 2e7817f609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -86,6 +86,10 @@ command.add(nil, {
end, end,
["core:open-file"] = function() ["core:open-file"] = function()
local view = core.active_view
if view and view.doc and view.doc.filename then
core.command_view:set_text((view.doc.filename:find("%.%.") and view.doc.abs_filename or view.doc.filename):match("(.*[/\\])(.+)$"))
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)))
end, function (text) end, function (text)