Skip to content

Commit

Permalink
fix: format with jq before to avoid flickering, and fix extmark id
Browse files Browse the repository at this point in the history
  • Loading branch information
rstcruzo committed Dec 1, 2024
1 parent e03845e commit ba7f18a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lua/http-nvim/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ba7f18a

Please sign in to comment.