Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: error when closing the result buffer and trying to reopen it #188

Merged
merged 2 commits into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading