Skip to content

Commit

Permalink
Allow interrupting a process by closing the console buffer, or by
Browse files Browse the repository at this point in the history
sending an interrupt via c-c
  • Loading branch information
CKolkey committed Oct 29, 2024
1 parent ad86259 commit 42ebd2a
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions lua/neogit/buffers/process/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ end

function M:close()
if self.buffer then
self.buffer:close_terminal_channel()
self.buffer:close()
self.buffer = nil
end
Expand Down Expand Up @@ -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
Expand All @@ -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),
["<esc>"] = hide(self),
},
n = {
[status_maps["Close"]] = hide(self),
["<esc>"] = hide(self),
["<c-c>"] = function()
pcall(self.process.stop, self.process)
end,
[status_maps["Close"]] = close(self),
["<esc>"] = close(self),
},
},
}

self.buffer:open_terminal_channel()

return self
end

Expand Down

0 comments on commit 42ebd2a

Please sign in to comment.