Merge pull request #869 from jgmdev/fix-loading-order

Initialization: load core views before user plugins
This commit is contained in:
Jefferson González 2022-03-06 21:22:53 -04:00 committed by GitHub
commit 6386bac4e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 31 deletions

View File

@ -719,7 +719,32 @@ function core.init()
core.threads = setmetatable({}, { __mode = "k" })
core.blink_start = system.get_time()
core.blink_timer = core.blink_start
core.redraw = true
core.visited_files = {}
core.restart_request = false
core.quit_request = false
-- We load core views before plugins that may need them.
core.root_view = RootView()
core.command_view = CommandView()
core.status_view = StatusView()
core.nag_view = NagView()
core.title_view = TitleView()
-- Some plugins (eg: console) require the nodes to be initialized to defaults
local cur_node = core.root_view.root_node
cur_node.is_primary_node = true
cur_node:split("up", core.title_view, {y = true})
cur_node = cur_node.b
cur_node:split("up", core.nag_view, {y = true})
cur_node = cur_node.b
cur_node = cur_node:split("down", core.command_view, {y = true})
cur_node = cur_node:split("down", core.status_view, {y = true})
-- Load defaiult commands first so plugins can override them
command.add_defaults()
-- Load user module, plugins and project module
local got_user_error, got_project_error = not core.load_user_directory()
local project_dir_abs = system.absolute_path(project_dir)
@ -744,27 +769,7 @@ function core.init()
end
end
core.redraw = true
core.visited_files = {}
core.restart_request = false
core.quit_request = false
core.root_view = RootView()
core.command_view = CommandView()
core.status_view = StatusView()
core.nag_view = NagView()
core.title_view = TitleView()
local cur_node = core.root_view.root_node
cur_node.is_primary_node = true
cur_node:split("up", core.title_view, {y = true})
cur_node = cur_node.b
cur_node:split("up", core.nag_view, {y = true})
cur_node = cur_node.b
cur_node = cur_node:split("down", core.command_view, {y = true})
cur_node = cur_node:split("down", core.status_view, {y = true})
command.add_defaults()
-- Load core plugins after user ones to let the user override them
local plugins_success, plugins_refuse_list = core.load_plugins()
do