Release: Docs Improvements and Bug Fixes (#460)

Miscellaneous bug fixes and improvements.

docs: various improvements (#445)
fix: don't jump to file from reviewer if it doesn't exist (#452)
fix: force linewise motion in suggestion keybinding (#454)
fix: prevent error after plenary job update (#456)
fix: fix JSON on Windows (#458)
fix: remove retry logic (#449)
fix: check whether comment can be created (#434)
This commit is contained in:
Harrison (Harry) Cramer
2025-01-18 11:22:24 -05:00
committed by GitHub
parent 495e64c8bc
commit 3b396a5e6b
5 changed files with 37 additions and 9 deletions

View File

@@ -68,6 +68,7 @@ func NewClient() (*Client, error) {
retryClient := retryablehttp.NewClient()
retryClient.HTTPClient.Transport = tr
retryClient.RetryMax = 0
gitlabOptions = append(gitlabOptions, gitlab.WithHTTPClient(retryClient.HTTPClient))
client, err := gitlab.NewClient(pluginOptions.AuthToken, gitlabOptions...)

View File

@@ -293,6 +293,13 @@ M.jump_to_file = function(tree)
u.notify("This comment was not left on a particular location", vim.log.levels.WARN)
return
end
if vim.fn.filereadable(root_node.file_name) == 0 then
u.notify(
string.format("The file %s for which the comment was made doesn't exist in HEAD.", root_node.file_name),
vim.log.levels.WARN
)
return
end
vim.cmd.tabnew()
local line_number = get_new_line(root_node) or get_old_line(root_node)
if line_number == nil then

View File

@@ -17,6 +17,7 @@ M.run_job = function(endpoint, method, body, callback)
-- This handler will handle all responses from the Go server. Anything with a successful
-- status will call the callback (if it is supplied for the job). Otherwise, it will print out the
-- success message or error message and details from the Go server.
local stderr = {}
Job:new({
command = "curl",
args = args,
@@ -55,13 +56,20 @@ M.run_job = function(endpoint, method, body, callback)
end
end, 0)
end,
on_stderr = function()
vim.defer_fn(function()
u.notify("Could not run command!", vim.log.levels.ERROR)
end, 0)
on_stderr = function(_, data)
if data then
table.insert(stderr, data)
end
end,
on_exit = function(_, status)
on_exit = function(code, status)
vim.defer_fn(function()
if #stderr ~= 0 then
u.notify(
string.format("Could not run command `%s %s`! Stderr was:", code.command, table.concat(code.args, " ")),
vim.log.levels.ERROR
)
vim.notify(string.format("%s", table.concat(stderr, "\n")), vim.log.levels.ERROR)
end
if status ~= 0 then
u.notify(string.format("Go server exited with non-zero code: %d", status), vim.log.levels.ERROR)
end

View File

@@ -109,7 +109,6 @@ M.jump = function(file_name, line_number, new_buffer)
return
end
vim.api.nvim_set_current_tabpage(M.tabnr)
vim.cmd("DiffviewFocusFiles")
local view = diffview_lib.get_current_view()
if view == nil then
u.notify("Could not find Diffview view", vim.log.levels.ERROR)
@@ -120,6 +119,13 @@ M.jump = function(file_name, line_number, new_buffer)
local file = List.new(files):find(function(file)
return file.path == file_name
end)
if file == nil then
u.notify(
string.format("The file %s for which the comment was made doesn't exist in HEAD.", file_name),
vim.log.levels.WARN
)
return
end
async.await(view:set_file(file))
local layout = view.cur_layout
@@ -325,7 +331,8 @@ local set_keymaps = function(bufnr, keymaps)
if keymaps.reviewer.create_comment ~= false then
-- Set keymap for repeated operator keybinding
vim.keymap.set("o", keymaps.reviewer.create_comment, function()
vim.api.nvim_cmd({ cmd = "normal", bang = true, args = { tostring(vim.v.count1) .. "$" } }, {})
-- The "V" in "V%d$" forces linewise motion, see `:h o_V`
vim.api.nvim_cmd({ cmd = "normal", bang = true, args = { string.format("V%d$", vim.v.count1) } }, {})
end, {
buffer = bufnr,
desc = "Create comment for [count] lines",
@@ -355,7 +362,8 @@ local set_keymaps = function(bufnr, keymaps)
if keymaps.reviewer.create_suggestion ~= false then
-- Set keymap for repeated operator keybinding
vim.keymap.set("o", keymaps.reviewer.create_suggestion, function()
vim.api.nvim_cmd({ cmd = "normal", bang = true, args = { tostring(vim.v.count1) .. "$" } }, {})
-- The "V" in "V%d$" forces linewise motion, see `:h o_V`
vim.api.nvim_cmd({ cmd = "normal", bang = true, args = { string.format("V%d$", vim.v.count1) } }, {})
end, {
buffer = bufnr,
desc = "Create suggestion for [count] lines",

View File

@@ -26,7 +26,11 @@ M.start = function(callback)
state.chosen_mr_iid = 0 -- Do not let this interfere with subsequent reviewer.open() calls
local settings = vim.json.encode(go_server_settings)
local command = string.format("%s '%s'", state.settings.bin, settings)
if vim.fn.has("win32") then
settings = settings:gsub('"', '\\"')
end
local command = string.format('"%s" "%s"', state.settings.bin, settings)
local job_id = vim.fn.jobstart(command, {
on_stdout = function(_, data)