Skip to content

Commit

Permalink
fix: "Failed to rename buffer" when trying to reopen the result buffe…
Browse files Browse the repository at this point in the history
…r in split mode after having closed it manually
  • Loading branch information
Javier Ugarte committed Aug 2, 2024
1 parent e498c32 commit 6700427
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lua/hurl/split.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ local M = {}
--- - headers table
---@param type 'json' | 'html' | 'xml' | 'text'
M.show = function(data, type)
local function quit()
-- set buffer name to empty string so it wouldn't conflict when next time buffer opened
vim.api.nvim_buf_set_name(split.bufnr, '')
vim.cmd('q')
split:unmount()
end
-- mount/open the component
split:mount()

Expand All @@ -29,7 +35,8 @@ M.show = function(data, type)
if _HURL_GLOBAL_CONFIG.auto_close then
-- unmount component when buffer is closed
split:on(event.BufLeave, function()
split:unmount()
quit()
-- split:unmount()
end)
end

Expand Down Expand Up @@ -75,12 +82,6 @@ M.show = function(data, type)
vim.api.nvim_feedkeys('zx', 'n', true)
end, 200)

local function quit()
-- set buffer name to empty string so it wouldn't conflict when next time buffer opened
vim.api.nvim_buf_set_name(split.bufnr, '')
vim.cmd('q')
split:unmount()
end
split:map('n', _HURL_GLOBAL_CONFIG.mappings.close, function()
quit()
end)
Expand Down

0 comments on commit 6700427

Please sign in to comment.