Skip to content

Commit

Permalink
Error on new or re-ordered lines
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc-stripe committed Jul 30, 2024
1 parent de5f2eb commit d9e7888
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Improved UI and workflow for the Neovim quickfix

TODO finish docs

<!-- TOC -->

- [Requirements](#requirements)
Expand Down
24 changes: 19 additions & 5 deletions lua/quicker/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,13 @@ end
local function add_qf_error(bufnr, lnum, text, text_hl)
local line = vim.api.nvim_buf_get_lines(bufnr, lnum - 1, lnum, true)[1]
local col = line:find(config.display.borders.vert, 1, true)
col = line:find(config.display.borders.vert, col + config.display.borders.vert:len(), true)
+ config.display.borders.vert:len()
- 1
if col then
col = line:find(config.display.borders.vert, col + config.display.borders.vert:len(), true)
+ config.display.borders.vert:len()
- 1
else
col = 0
end
local offset = vim.api.nvim_strwidth(line:sub(1, col))
local ns = vim.api.nvim_create_namespace("quicker_err")
vim.api.nvim_buf_set_extmark(bufnr, ns, lnum - 1, col, {
Expand Down Expand Up @@ -233,9 +237,19 @@ local function save_changes(bufnr, loclist_win)
(function()
local parsed = parse_line(line)
local found_idx = find_next(saved_items, item_idx, parsed)

-- If we didn't find a match, the line was most likely added or reordered
if not found_idx then
-- TODO FIXME log an error that we couldn't find the line
-- Adding and reordering lines is not allowed
add_qf_error(
bufnr,
i,
"quicker.nvim does not support adding or reordering quickfix items",
"DiagnosticError"
)
if winid then
vim.api.nvim_win_set_cursor(winid, { i, 0 })
end
exit_early = true
return
end
item_idx = found_idx + 1
Expand Down

0 comments on commit d9e7888

Please sign in to comment.