Skip to content

Commit

Permalink
Remove header check, handle nil content
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Jun 17, 2024
1 parent d5cce0b commit d82aa04
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions lua/hurl/popup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,26 +86,18 @@ M.show = function(data, type)

-- Add headers to the top
local headers_table = utils.render_header_table(data.headers)
-- Hide header block if empty headers
if headers_table.line == 0 then
vim.api.nvim_win_close(popups.top.winid, true)
else
if headers_table.line > 0 then
vim.api.nvim_buf_set_lines(popups.top.bufnr, 0, 1, false, headers_table.headers)
end
if headers_table.line > 0 then
vim.api.nvim_buf_set_lines(popups.top.bufnr, 0, 1, false, headers_table.headers)
end

local content = utils.format(data.body, type)
if not content then
utils.log_info('No content')
return
end
if content then
-- Add content to the bottom
vim.api.nvim_buf_set_lines(popups.bottom.bufnr, 0, -1, false, content)

-- Add content to the bottom
vim.api.nvim_buf_set_lines(popups.bottom.bufnr, 0, -1, false, content)

-- Set content to highlight, refer https://github.com/MunifTanjim/nui.nvim/issues/76#issuecomment-1001358770
vim.api.nvim_buf_set_option(popups.bottom.bufnr, 'filetype', type)
-- Set content to highlight
vim.api.nvim_buf_set_option(popups.bottom.bufnr, 'filetype', type)
end
end

M.clear = function()
Expand Down

0 comments on commit d82aa04

Please sign in to comment.