Merge pull request #34 from budRich/user-module-auto-reload2

User module auto reload
This commit is contained in:
Francesco 2021-02-16 20:52:06 +00:00 committed by GitHub
commit 1decf67b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -107,12 +107,6 @@ command.add(nil, {
["core:open-user-module"] = function() ["core:open-user-module"] = function()
local user_module_doc = core.open_doc(USERDIR .. "/init.lua") local user_module_doc = core.open_doc(USERDIR .. "/init.lua")
if not user_module_doc then return end if not user_module_doc then return end
local doc_save = user_module_doc.save
user_module_doc.save = function(self)
doc_save(self)
core.reload_module("core.style")
core.load_user_directory()
end
core.root_view:open_doc(user_module_doc) core.root_view:open_doc(user_module_doc)
end, end,

View File

@ -67,6 +67,10 @@ end
local function save(filename) local function save(filename)
doc():save(filename) doc():save(filename)
if doc().filename == (USERDIR .. PATHSEP .. "init.lua") then
core.reload_module("core.style")
core.load_user_directory()
end
core.log("Saved \"%s\"", doc().filename) core.log("Saved \"%s\"", doc().filename)
end end