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)
end
local function get_primary_node(node)
if node.is_primary_node then
return node
@ -446,18 +447,26 @@ local function get_primary_node(node)
end
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()
function RootView:get_active_node_default()
local node = self.root_node:get_node_for_view(core.active_view)
if node.locked then
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()
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
if view.doc == doc then
node:set_active_view(node.views[i])

View File

@ -213,7 +213,7 @@ local function begin_search(text, fn)
return
end
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