From ba7f18aa300e4950faf11975b50861750d62fd34 Mon Sep 17 00:00:00 2001 From: Rodrigo Santa Cruz Date: Sun, 1 Dec 2024 07:22:58 -0500 Subject: [PATCH] fix: format with jq before to avoid flickering, and fix extmark id --- lua/http-nvim/ui.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/http-nvim/ui.lua b/lua/http-nvim/ui.lua index fba2548..1be16a1 100644 --- a/lua/http-nvim/ui.lua +++ b/lua/http-nvim/ui.lua @@ -42,7 +42,9 @@ end local function body_to_lines(response, file_type) if file_type == "json" then - return vim.split(vim.fn.json_encode(response.body), "\n") + local json_body = vim.fn.json_encode(response.body) + local formatted_body = utils.format_if_jq_installed(json_body) + return vim.split(formatted_body, "\n") end return vim.split(response.body, "\n") @@ -92,8 +94,6 @@ local function show_response(request, response) vim.api.nvim_set_current_buf(buf) - vim.cmd([[silent exe "normal gq%"]]) - vim.keymap.set("n", "q", vim.cmd.close, { buffer = true }) vim.opt_local.winbar = winbar .. " (2/2)" @@ -148,7 +148,7 @@ M.set_request_state = function(request, state) local icon = Icons[state] local highlight = Highlights[state] - local extmark_id = request_line + local extmark_id = request_line + 1 -- +1 to avoid passing 0, it errors out local bufnr = request.source.route ---@cast bufnr integer