Skip to content

Commit

Permalink
Fix: error when closing the result buffer and trying to reopen it (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
javoscript authored Aug 3, 2024
1 parent e498c32 commit ddce6f8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 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,7 @@ 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()
end)
end

Expand Down Expand Up @@ -75,12 +81,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 ddce6f8

Please sign in to comment.