Abstracted open_doc out to allow for more easy overriding. (#1344)
This commit is contained in:
parent
1378c3d6a7
commit
389449853a
|
@ -441,6 +441,11 @@ function TreeView:toggle_expand(toggle)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function TreeView:open_doc(filename)
|
||||||
|
core.root_view:open_doc(core.open_doc(filename))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- init
|
-- init
|
||||||
local view = TreeView()
|
local view = TreeView()
|
||||||
local node = core.root_view:get_active_node()
|
local node = core.root_view:get_active_node()
|
||||||
|
@ -610,8 +615,7 @@ command.add(TreeView, {
|
||||||
if core.last_active_view and core.active_view == view then
|
if core.last_active_view and core.active_view == view then
|
||||||
core.set_active_view(core.last_active_view)
|
core.set_active_view(core.last_active_view)
|
||||||
end
|
end
|
||||||
local doc_filename = core.normalize_to_project_dir(item.abs_filename)
|
view:open_doc(core.normalize_to_project_dir(item.abs_filename))
|
||||||
core.root_view:open_doc(core.open_doc(doc_filename))
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -759,7 +763,7 @@ command.add(
|
||||||
local file = io.open(doc_filename, "a+")
|
local file = io.open(doc_filename, "a+")
|
||||||
file:write("")
|
file:write("")
|
||||||
file:close()
|
file:close()
|
||||||
core.root_view:open_doc(core.open_doc(doc_filename))
|
view:open_doc(doc_filename)
|
||||||
core.log("Created %s", doc_filename)
|
core.log("Created %s", doc_filename)
|
||||||
end,
|
end,
|
||||||
suggest = function(text)
|
suggest = function(text)
|
||||||
|
@ -803,8 +807,8 @@ local projectsearch = pcall(require, "plugins.projectsearch")
|
||||||
if projectsearch then
|
if projectsearch then
|
||||||
menu:register(function()
|
menu:register(function()
|
||||||
return view.hovered_item and view.hovered_item.type == "dir"
|
return view.hovered_item and view.hovered_item.type == "dir"
|
||||||
end, {
|
end, {
|
||||||
{ text = "Find in directory", command = "treeview:search-in-directory" }
|
{ text = "Find in directory", command = "treeview:search-in-directory" }
|
||||||
})
|
})
|
||||||
command.add(function()
|
command.add(function()
|
||||||
return view.hovered_item and view.hovered_item.type == "dir"
|
return view.hovered_item and view.hovered_item.type == "dir"
|
||||||
|
|
Loading…
Reference in New Issue