Remove redundant quickfix setup and tests #14

Merged
eleith merged 1 commits from refactor/remove-redundant-quickfix-code into main 2026-11-30 20:25:46 +00:00
5 changed files with 5 additions and 61 deletions

No files matched your search

+4
View File
@@ -17,6 +17,10 @@
- Fall back to filesystem lookup when Git cannot start.
- Remove stale quickfix entries when clearing comments without touching other lists.
### Changed
- Simplify quickfix setup and remove unused test helpers and redundant tests.
## [0.1.0] - 2026-09-30
- First tagged release.
-3
View File
@@ -430,9 +430,6 @@ function M.open(filter)
return false
end
list_id = quickfix.list(anchored, orphans)
if not list_id then
return
end
list_bufnr = vim.api.nvim_get_current_buf()
list_win = vim.api.nvim_get_current_win()
list_tab = vim.api.nvim_get_current_tabpage()
-7
View File
@@ -1,5 +1,3 @@
local notify = require("scratch_comments.ui.notify")
local M = {}
---@param text string
@@ -39,11 +37,6 @@ end
---@param views ScratchCommentView[]
---@param orphans ScratchComment[]
function M.list(views, orphans)
if #views + #orphans == 0 then
notify.info("No comments")
return
end
vim.fn.setqflist({}, " ", { title = "Comments", items = M.items(views, orphans) })
local id = vim.fn.getqflist({ id = 0 }).id
vim.cmd.copen()
+1 -27
View File
@@ -131,18 +131,6 @@ describe("the comment list manager", function()
expect.equality(vim.fn.getqflist({ winid = 0 }).winid, 0)
end)
it("leaves the source cursor alone while browsing", function()
vim.api.nvim_win_set_cursor(0, { 1, 0 })
local source_win = vim.api.nvim_get_current_win()
vim.cmd.CommentList()
vim.api.nvim_win_set_cursor(0, { 2, 0 })
vim.api.nvim_exec_autocmds("CursorMoved", { buffer = 0 })
expect.equality(vim.api.nvim_win_get_cursor(source_win)[1], 1)
vim.cmd("normal \r")
expect.equality(vim.api.nvim_win_get_cursor(source_win)[1], 3)
expect.equality(#helpers.every_float(), 0)
end)
it("doesn't return an orphan editor to another plugin's quickfix list", function()
vim.cmd("1d")
helpers.text_changed()
@@ -781,6 +769,7 @@ describe("quickfix navigation", function()
local source_win = vim.api.nvim_get_current_win()
vim.cmd.CommentList()
vim.cmd("normal j")
vim.api.nvim_exec_autocmds("CursorMoved", { buffer = 0 })
expect.equality(vim.api.nvim_win_get_cursor(0)[1], 2)
expect.equality(vim.fn.getqflist({ idx = 0 }).idx, 1)
expect.equality(vim.api.nvim_win_get_cursor(source_win)[1], 1)
@@ -986,12 +975,6 @@ describe("quickfix navigation", function()
expect.equality(#helpers.every_float(), 0)
expect.equality(vim.bo.buftype, "quickfix")
end)
it("does not leave any card behind when the list closes", function()
vim.cmd.CommentList()
vim.cmd.cclose()
expect.equality(#helpers.every_float(), 0)
end)
end)
describe("comments in several files", function()
@@ -1018,12 +1001,3 @@ describe("comments in several files", function()
)
end)
end)
describe("a snippet containing a code fence", function()
it("is fenced with four backticks", function()
helpers.buffer("fence.md", { "```lua", "x = 1", "```" })
vim.cmd("1,3Comment")
helpers.write("on a fence")
expect.no_equality(scratch.render():find("````md\n```lua", 1, true), nil)
end)
end)
-24
View File
@@ -84,27 +84,6 @@ function M.sign_at(line)
return nil
end
local select = vim.ui.select
---@type any[] the items the last vim.ui.select offered
M.offered = {}
---@type string[] how the last vim.ui.select showed its items
M.labels = {}
-- Answers each vim.ui.select with the next index given, then with 1. An index
-- past the items (such as 0) cancels.
---@param ... integer
function M.pick(...)
local choices = { ... }
---@diagnostic disable-next-line: duplicate-set-field -- test fake
vim.ui.select = function(items, opts, callback)
M.offered = items
M.labels = vim.tbl_map(opts.format_item or tostring, items)
callback(items[table.remove(choices, 1) or 1])
end
end
-- Headless edits share one undo block unless it is broken explicitly.
function M.undo_break()
vim.o.undolevels = vim.o.undolevels
@@ -134,9 +113,6 @@ function M.reset()
require("scratch_comments").clear()
require("scratch_comments").toggle(true)
vim.cmd("silent! %bwipeout!")
vim.ui.select = select
M.offered = {}
M.labels = {}
vim.wait(0)
M.notifications = {}
end