diff --git a/lua/neogit/buffers/process/init.lua b/lua/neogit/buffers/process/init.lua index 7f8b1efd6..4f46aa46d 100644 --- a/lua/neogit/buffers/process/init.lua +++ b/lua/neogit/buffers/process/init.lua @@ -43,6 +43,7 @@ end function M:close() if self.buffer then + self.buffer:close_terminal_channel() self.buffer:close() self.buffer = nil end @@ -92,8 +93,9 @@ function M:flush_content() end end -local function hide(self) +local function close(self) return function() + self.process:stop() self:close() end end @@ -111,29 +113,20 @@ function M:open() open = false, buftype = false, kind = config.values.preview_buffer.kind, - on_detach = function() - self.buffer:close_terminal_channel() - self.buffer = nil + after = function(buffer) + buffer:open_terminal_channel() end, - autocmds = { - ["WinLeave"] = function() - pcall(self.close, self) - end, - }, mappings = { - t = { - [status_maps["Close"]] = hide(self), - [""] = hide(self), - }, n = { - [status_maps["Close"]] = hide(self), - [""] = hide(self), + [""] = function() + pcall(self.process.stop, self.process) + end, + [status_maps["Close"]] = close(self), + [""] = close(self), }, }, } - self.buffer:open_terminal_channel() - return self end