Skip to content

Commit 8e0336d

Browse files
committed
cache filetype for each bufnr
1 parent b9bf506 commit 8e0336d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lua/quicker/display.lua

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ local function highlight_buffer_when_entered(qfbufnr, info)
248248
info.end_idx = vim.api.nvim_buf_line_count(qfbufnr)
249249
info.regions = {}
250250
info.empty_regions = {}
251+
info.ft = {}
251252
schedule_highlights(info)
252253
end,
253254
})
@@ -320,7 +321,16 @@ add_qf_highlights = function(info)
320321
loaded = true
321322
end
322323

323-
local ft = vim.filetype.match({ buf = item.bufnr })
324+
local ft = info.ft[item.bufnr]
325+
if ft == nil then
326+
if loaded then
327+
ft = vim.bo[item.bufnr].filetype
328+
else
329+
ft = vim.filetype.match({ buf = item.bufnr })
330+
end
331+
info.ft[item.bufnr] = ft
332+
end
333+
324334
if config.highlight.treesitter and ft then
325335
info.regions[ft] = info.regions[ft] or {}
326336
info.empty_regions[ft] = info.empty_regions[ft] or {}
@@ -428,6 +438,7 @@ end
428438
---@field end_idx integer
429439
---@field regions table<string, Range4[][]>
430440
---@field empty_regions table<string, Range4[][]>
441+
---@field ft table<integer, string|nil >
431442
---@field previous_item QuickFixItem
432443
---@field winid integer
433444
---@field quickfix 1|0
@@ -594,6 +605,7 @@ function M.quickfixtextfunc(info)
594605
if info.end_idx == #items then
595606
info.regions = {}
596607
info.empty_regions = {}
608+
info.ft = {}
597609
schedule_highlights(info)
598610

599611
if qf_list.qfbufnr > 0 then

0 commit comments

Comments
 (0)