From 42ebd2ae70ce31b485e7dea99504796498cb18f8 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 29 Oct 2024 10:08:01 +0100 Subject: [PATCH] Allow interrupting a process by closing the console buffer, or by sending an interrupt via c-c --- lua/neogit/buffers/process/init.lua | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) 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