From cb3f98d935842836cc115e8c9e4b38c1380fbb6b Mon Sep 17 00:00:00 2001 From: Cameron Ring Date: Wed, 25 Sep 2024 17:22:16 -0700 Subject: [PATCH] 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. --- lua/telescope/previewers/buffer_previewer.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope/previewers/buffer_previewer.lua b/lua/telescope/previewers/buffer_previewer.lua index d0756ff69e..da11227e9e 100644 --- a/lua/telescope/previewers/buffer_previewer.lua +++ b/lua/telescope/previewers/buffer_previewer.lua @@ -1116,7 +1116,7 @@ previewers.highlights = defaulter(function(_) vim.schedule(function() vim.api.nvim_buf_call(self.state.bufnr, function() 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] -- 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)