Skip to content

Commit 6344af3

Browse files
committed
experiment with catching E790 when doing undojoin
1 parent 2f98635 commit 6344af3

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

lua/shell/init.lua

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,28 @@ local StopShell = function(channel_id)
66
end
77
end
88

9+
-- This is based on https://github.com/Robitx/gp.nvim/commit/5ccf0d28c6fbc206ebd853a9a2f1b1ab9878cdab
10+
local undojoin = function(buf)
11+
if not buf or not vim.api.nvim_buf_is_loaded(buf) then
12+
return
13+
end
14+
local status, result = pcall(vim.cmd.undojoin)
15+
if not status then
16+
if result:match("E790") then
17+
return
18+
end
19+
M.error("Error running undojoin: " .. vim.inspect(result))
20+
end
21+
end
22+
923
local StartShell = function(opts)
1024
local command = opts.command
1125
local buf = opts.buf
1226
local follow = opts.follow
1327

1428
local output_prefix = ""
1529
local insert_output = function(bufnr, data)
16-
vim.cmd.undojoin()
30+
undojoin(bufnr)
1731
-- check if bufnr still exists
1832
if vim.api.nvim_buf_is_loaded(bufnr) == false then
1933
return

0 commit comments

Comments
 (0)