fix(highlights): previewer show correct highlight group (#3305)

Fixes a minor bug in the builtin highlights picker where having
`Comment` selected in the picker shows `SpecialComment` in the
previewer. Only happens when the selected highlight is a suffix of
another highlight and the other highlight occurs first.
This commit is contained in:
Cameron Ring
2024-09-25 17:22:16 -07:00
committed by GitHub
parent 6b08cdcc22
commit cb3f98d935

View File

@@ -1116,7 +1116,7 @@ previewers.highlights = defaulter(function(_)
vim.schedule(function() vim.schedule(function()
vim.api.nvim_buf_call(self.state.bufnr, function() vim.api.nvim_buf_call(self.state.bufnr, function()
vim.cmd "keepjumps norm! gg" vim.cmd "keepjumps norm! gg"
vim.fn.search(entry.value .. " ") vim.fn.search("^" .. entry.value .. " ")
local lnum = vim.api.nvim_win_get_cursor(self.state.winid)[1] local lnum = vim.api.nvim_win_get_cursor(self.state.winid)[1]
-- That one is actually a match but its better to use it like that then matchadd -- That one is actually a match but its better to use it like that then matchadd
pcall(vim.api.nvim_buf_clear_namespace, self.state.bufnr, ns_previewer, 0, -1) pcall(vim.api.nvim_buf_clear_namespace, self.state.bufnr, ns_previewer, 0, -1)