Skip to content

Commit 05b0a2b

Browse files
committed
fix: fix hl.range ns
1 parent 261cba7 commit 05b0a2b

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

lua/quicktest/colored_printer.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ local api = vim.api
99
local ColoredPrinter = {}
1010
ColoredPrinter.__index = ColoredPrinter
1111

12+
local ns = vim.api.nvim_create_namespace("colored_printer_hl")
13+
1214
function ColoredPrinter.new()
1315
local self = setmetatable({}, ColoredPrinter)
1416
self.color_groups = {}
@@ -20,6 +22,13 @@ function ColoredPrinter.new()
2022
return self
2123
end
2224

25+
--- @param buf integer
26+
--- @param start_line integer
27+
--- @param end_line_exclusive integer
28+
function ColoredPrinter:clear(buf, start_line, end_line_exclusive)
29+
vim.api.nvim_buf_clear_namespace(buf, ns, start_line or 0, end_line_exclusive or -1)
30+
end
31+
2332
---@param index integer
2433
function ColoredPrinter:get_256_color(index)
2534
-- Standard 16 colors (0-15)
@@ -435,7 +444,7 @@ function ColoredPrinter:set_next_lines(lines, buf, lines_count)
435444
for _, h in ipairs(hl) do
436445
-- print("[" .. h.start .. "," .. h.end_ .. ")", get_highlight_def(h.group))
437446

438-
vim.hl.range(buf, -1, h.group, { lines_count - 1 + i, h.start }, { lines_count - 1 + i, h.end_ })
447+
vim.hl.range(buf, ns, h.group, { lines_count - 1 + i, h.start }, { lines_count - 1 + i, h.end_ })
439448
-- api.nvim_buf_add_highlight(buf, -1, h.group, lines_count - 1 + i, h.start, h.end_)
440449
end
441450
end

lua/quicktest/module.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ function M.run(adapter, params, config, opts)
233233

234234
for _, buf in ipairs(ui.get_buffers()) do
235235
vim.api.nvim_buf_set_lines(buf, 0, -1, false, {})
236-
vim.api.nvim_buf_clear_namespace(buf, -1, 0, -1)
236+
colorized_printer:clear(buf, 0, -1)
237237

238238
ui.scroll_down(buf)
239239
end

0 commit comments

Comments
 (0)