From 259de54c333b9d761316da1c01adaf8e2d8b428a Mon Sep 17 00:00:00 2001 From: Guldoman Date: Tue, 28 Jun 2022 04:21:43 +0200 Subject: [PATCH] Fix opening `LogView` when reloading customizations As `reload_customizations` was called during save operations, opening the `LogView` changed `core.active_view` which caused some errors to be thrown. --- data/core/init.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index f8459e3f..757bbcd0 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -68,15 +68,19 @@ local function reload_customizations() local user_error = not core.load_user_directory() local project_error = not core.load_project_module() if user_error or project_error then - local LogView = require "core.logview" - local rn = core.root_view.root_node - for _,v in pairs(core.root_view.root_node:get_children()) do - if v:is(LogView) then - rn:get_node_for_view(v):set_active_view(v) - return + -- Use core.add_thread to delay opening the LogView, as opening + -- it directly here disturbs the normal save operations. + core.add_thread(function() + local LogView = require "core.logview" + local rn = core.root_view.root_node + for _,v in pairs(core.root_view.root_node:get_children()) do + if v:is(LogView) then + rn:get_node_for_view(v):set_active_view(v) + return + end end - end - command.perform("core:open-log") + command.perform("core:open-log") + end) end end