Fix find in project problem with get_active_view

This commit is contained in:
Francesco Abbate 2020-12-28 23:35:52 +01:00
parent ddd56ec615
commit b7168b5ebb
2 changed files with 15 additions and 6 deletions

View File

@ -437,6 +437,7 @@ function RootView:get_active_node()
return self.root_node:get_node_for_view(core.active_view) return self.root_node:get_node_for_view(core.active_view)
end end
local function get_primary_node(node) local function get_primary_node(node)
if node.is_primary_node then if node.is_primary_node then
return node return node
@ -446,18 +447,26 @@ local function get_primary_node(node)
end end
end end
function RootView:get_primary_node()
return get_primary_node(self.root_node)
end
function RootView:open_doc(doc) function RootView:get_active_node_default()
local node = self:get_active_node() local node = self.root_node:get_node_for_view(core.active_view)
if node.locked then if node.locked then
local default_view = self:get_primary_node().views[1] local default_view = self:get_primary_node().views[1]
assert(default_view, "internal error: cannot find original document node.") assert(default_view, "internal error: cannot find original document node.")
core.set_active_view(default_view) core.set_active_view(default_view)
node = self:get_active_node() node = self:get_active_node()
end end
return node
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_default()
for i, view in ipairs(node.views) do for i, view in ipairs(node.views) do
if view.doc == doc then if view.doc == doc then
node:set_active_view(node.views[i]) node:set_active_view(node.views[i])

View File

@ -213,7 +213,7 @@ local function begin_search(text, fn)
return return
end end
local rv = ResultsView(text, fn) local rv = ResultsView(text, fn)
core.root_view:get_active_node():add_view(rv) core.root_view:get_active_node_default():add_view(rv)
end end