Skip to content

Commit 0ca1a4d

Browse files
committed
cache filetype for each bufnr
1 parent dd61059 commit 0ca1a4d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lua/quicker/display.lua

Lines changed: 9 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,12 @@ 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+
ft = loaded and vim.bo[item.bufnr].filetype or vim.filetype.match({ buf = item.bufnr })
327+
info.ft[item.bufnr] = ft
328+
end
329+
324330
if config.highlight.treesitter and ft then
325331
info.regions[ft] = info.regions[ft] or {}
326332
info.empty_regions[ft] = info.empty_regions[ft] or {}
@@ -428,6 +434,7 @@ end
428434
---@field end_idx integer
429435
---@field regions table<string, Range4[][]>
430436
---@field empty_regions table<string, Range4[][]>
437+
---@field ft table<integer, string|nil>
431438
---@field previous_item QuickFixItem
432439
---@field winid integer
433440
---@field quickfix 1|0
@@ -594,6 +601,7 @@ function M.quickfixtextfunc(info)
594601
if info.end_idx == #items then
595602
info.regions = {}
596603
info.empty_regions = {}
604+
info.ft = {}
597605
schedule_highlights(info)
598606

599607
if qf_list.qfbufnr > 0 then

0 commit comments

Comments
 (0)