Open jps327 opened 21 hours ago
A fix for this is to update the searchAndOpenFold
function in timed-highlight.lua
to the following:
local function searchAndOpenFold(key)
-- Get the current search term
local search_term = vim.fn.getreg('/')
-- Use pcall to safely execute the command and catch any errors
local success, _ = pcall(function()
vim.cmd('normal! ' .. key)
end)
if not success then
vim.api.nvim_err_writeln('E486: Pattern not found: ' .. search_term)
end
if string.find(vim.o.foldopen, "search") and vim.fn.foldclosed('.') ~= -1 then
vim.cmd('normal! zv')
end
require('timed-highlight').turn_off_highlight_after_expiration()
end
Basically, to use pcall
to wrap vim.cmd
to avoid printing the entire stack trace, and then we manually write the error instead to nvim.
Let me know if you want me to submit a PR or if its easier for you to just add this fix.
Thanks for putting together this plugin! It's exactly what I'm looking for to clear search highlights on their own.
It works smoothly but I found a bug.
Steps to reproduce
Expected behavior When pressing
n
orN
, the error message should just continue being the normal error message ("Pattern not found") rather than a stack traceback.My setup I am using Lazy to install plugins. This is my configuration as per the Readme:
Output from
nvim -v
:Let me know if you need anything else to debug & fix this! Thanks again for a helpful plugin.