Skip to content

Commit

Permalink
fix(return): return causing early exit when paired with auto_toc.exit…
Browse files Browse the repository at this point in the history
…_nvim
  • Loading branch information
benlubas authored and vhyrro committed Jul 6, 2024
1 parent 0255c2d commit 959b8a2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lua/neorg/modules/core/neorgcmd/commands/return/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,22 @@ module.on_event = function(event)
-- Get all the buffers
local buffers = vim.api.nvim_list_bufs()

local to_delete = {}
for _, buffer in ipairs(buffers) do
if vim.fn.buflisted(buffer) == 1 then
-- If the listed buffer we're working with has a .norg extension then remove it (not forcibly)
if vim.endswith(vim.api.nvim_buf_get_name(buffer), ".norg") then
vim.api.nvim_buf_delete(buffer, {})
if not vim.endswith(vim.api.nvim_buf_get_name(buffer), ".norg") then
vim.api.nvim_win_set_buf(0, buffer)
break
else
table.insert(to_delete, buffer)
end
end
end

for _, buffer in ipairs(to_delete) do
vim.api.nvim_buf_delete(buffer, {})
end
end
end

Expand Down

0 comments on commit 959b8a2

Please sign in to comment.