Skip to content

Commit

Permalink
fix(ignoreRule): forward-searching not working for single diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgrieser committed Nov 17, 2024
1 parent 8ddffe1 commit a4274a3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lua/rulebook/diagnostic-actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ local function validDiagObj(diag)
return true
end

---@param diag vim.Diagnostic
local function moveCursorToDiagnostic(diag)
vim.api.nvim_win_set_cursor(0, { diag.lnum + 1, diag.col })
end

--------------------------------------------------------------------------------

---@param diag vim.Diagnostic
Expand Down Expand Up @@ -171,6 +176,7 @@ function M.selectRule(operation)

-- autoselect if only one diagnostic
if #diagsAtLine == 1 then
moveCursorToDiagnostic(diagsAtLine[1])
actions[operation](diagsAtLine[1])
return
end
Expand Down Expand Up @@ -202,13 +208,7 @@ function M.selectRule(operation)
end,
}, function(diag)
if not diag then return end -- user aborted

-- move cursor to location where we add the comment
if operation == "ignoreRule" and startLine ~= lnum then
vim.api.nvim_win_set_cursor(0, { lnum + 1, 0 })
vim.cmd("normal! ^")
end

moveCursorToDiagnostic(diag)
actions[operation](diag)
end)
end
Expand Down

0 comments on commit a4274a3

Please sign in to comment.