From d82aa04e4cd1bd26ce776105b06e07a35bf849fa Mon Sep 17 00:00:00 2001 From: "sweep-ai[bot]" <128439645+sweep-ai[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 17:41:14 +0000 Subject: [PATCH] Remove header check, handle nil content --- lua/hurl/popup.lua | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/lua/hurl/popup.lua b/lua/hurl/popup.lua index 3c7c7d1..1c3196e 100644 --- a/lua/hurl/popup.lua +++ b/lua/hurl/popup.lua @@ -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()