Use get_primary_node instead of Rootview:get_primary_view

This commit is contained in:
Francesco Abbate 2020-12-14 14:19:28 +01:00
parent d18eef4ef0
commit 499f085045
2 changed files with 8 additions and 11 deletions

View File

@ -264,7 +264,7 @@ function core.init()
core.command_view = CommandView()
core.status_view = StatusView()
core.root_view.root_node.is_primary_view = true
core.root_view.root_node.is_primary_node = true
core.root_view.root_node:split("down", core.command_view, true)
core.root_view.root_node.b:split("down", core.status_view, true)

View File

@ -399,7 +399,7 @@ function Node:close_all_docviews()
i = i + 1
end
end
if #self.views == 0 and self.is_primary_view then
if #self.views == 0 and self.is_primary_node then
self:add_view(EmptyView())
end
else
@ -434,26 +434,23 @@ function RootView:get_active_node()
return self.root_node:get_node_for_view(core.active_view)
end
local function get_primary_view(node)
if node.is_primary_view then
local function get_primary_node(node)
if node.is_primary_node then
return node
end
if node.type ~= "leaf" then
return get_primary_view(node.a) or get_primary_view(node.b)
return get_primary_node(node.a) or get_primary_node(node.b)
end
end
function RootView:get_primary_view()
local node = get_primary_view(self.root_node)
if node then
return node.views[1]
end
function RootView:get_primary_node()
return get_primary_node(self.root_node)
end
function RootView:open_doc(doc)
local node = self:get_active_node()
if node.locked then
local default_view = self:get_primary_view()
local default_view = self:get_primary_node().views[1]
assert(default_view, "internal error: cannot find original document node.")
core.set_active_view(default_view)
node = self:get_active_node()