Skip to content

Commit

Permalink
Merge pull request #18 from Guldoman/PR_fix_close
Browse files Browse the repository at this point in the history
Fix closing `TerminalView` when its `Node` changed
  • Loading branch information
adamharrison authored Aug 22, 2023
2 parents f12a74e + dd90dd6 commit c30a281
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plugins/terminal/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ end

function TerminalView:close()
if self.terminal then self.terminal:close() end
if self.node then self.node:close_view(core.root_view.root_node, self) end
local node = core.root_view.root_node:get_node_for_view(self)
node:close_view(core.root_view.root_node, self)
if core.terminal_view == self then core.terminal_view = nil end
self.terminal = nil
self.routine = nil
Expand Down Expand Up @@ -619,7 +620,7 @@ command.add(nil, {
["terminal:toggle-drawer"] = function()
if not core.terminal_view then
core.terminal_view = TerminalView(config.plugins.terminal)
core.terminal_view.node = core.root_view:get_active_node():split("down", core.terminal_view, { y = true }, true)
core.root_view:get_active_node_default():split("down", core.terminal_view, { y = true }, true)
core.set_active_view(core.terminal_view)
else
core.terminal_view:close()
Expand All @@ -636,9 +637,7 @@ command.add(nil, {
end,
["terminal:open-tab"] = function()
local tv = TerminalView(config.plugins.terminal)
local node = core.root_view:get_active_node_default()
node:add_view(tv)
tv.node = node
core.root_view:get_active_node_default():add_view(tv)
end
})
command.add(function() return core.terminal_view and core.active_view ~= core.terminal_view end, {
Expand Down

0 comments on commit c30a281

Please sign in to comment.