Skip to content

Commit 6481b37

Browse files
committed
delete buffer created by opening via :e Shell://date, because Shell command is creating a new buffer
1 parent e30031b commit 6481b37

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

lua/shellpad/init.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,14 @@ M.setup = function(_)
298298

299299
vim.api.nvim_create_autocmd({"BufReadCmd"}, {
300300
pattern = "Shell://*",
301-
callback = function()
302-
-- Convert buffer to a scratch buffer
303-
vim.cmd("setlocal buftype=nofile")
301+
callback = function(event)
302+
-- a buffer is created later by StartShell(), so delete event.buf
303+
vim.api.nvim_buf_delete(event.buf, { force = true })
304304

305-
local filename = vim.fn.expand("<afile>")
305+
local filename = event.file
306306
local prefix_length = string.len("Shell://")
307307
local full_command = string.sub(filename, prefix_length + 1)
308+
308309
vim.cmd(string.format("Shell %s", full_command))
309310
end,
310311
group = vim.api.nvim_create_augroup('shellpad', { clear = true }),

0 commit comments

Comments
 (0)