From 32735077e74bf288c9463e167a07c2be98b96052 Mon Sep 17 00:00:00 2001 From: barrancojared <51723690+jaredbarranco@users.noreply.github.com> Date: Sat, 15 Feb 2025 13:03:06 -0800 Subject: [PATCH] Use temp file for non-windows jq actions use temp_file for non-windows is_valid debug is_valid back to original debug loggers more debug loggers fix debug log exit_status remove redundant debugs, add validity check debug bool to string debugging debugging debugging debugging In jq.lua, use temp file for jq actions. remove debug line --- lua/json-nvim/jq.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lua/json-nvim/jq.lua b/lua/json-nvim/jq.lua index fcf7d3a..f5d1e66 100644 --- a/lua/json-nvim/jq.lua +++ b/lua/json-nvim/jq.lua @@ -32,7 +32,8 @@ function M.get_formatted(input) cmd = "jq . " .. temp_file_path result = vim.fn.system(cmd) else - cmd = string.format("echo '%s' | jq .", input) + write_to_temp(input) + cmd = "jq . -e " .. temp_file_path result = vim.fn.system(cmd) end @@ -51,11 +52,11 @@ function M.get_collapsed(input) result = vim.fn.system(cmd) result = vim.fn.substitute(result, [[\n]], "", "g") else - cmd = string.format("echo '%s' | jq -c .", input) + write_to_temp(input) + cmd = "jq . -e " .. temp_file_path result = vim.fn.system(cmd) - result = result:gsub("[\n\r]", "") + result = result:gsub("\r?\n", "") end - return result end @@ -72,7 +73,8 @@ function M.get_rawed(input) result = vim.fn.system(cmd) result = vim.fn.substitute(result, [[\n]], "", "g") else - cmd = string.format("echo '%s' | jq -r .", input) + write_to_temp(input) + cmd = "jq . -r " .. temp_file_path result = vim.fn.system(cmd) result = result:gsub("[\n\r]", "") end @@ -96,9 +98,9 @@ function M.is_valid(input) return exit_status == 0 else - cmd = string.format("echo '%s' | jq -e .", input) + write_to_temp(input) + cmd = "jq . -e " .. temp_file_path .. "