1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

fix hlslens issue when no pattern is found

The captured error message is not correct before.
This commit is contained in:
jdhao 2023-09-01 21:21:16 +02:00
parent 63ff776758
commit e92362041c

View File

@ -12,10 +12,11 @@ local activate_hlslens = function(direction)
local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction) local cmd = string.format("normal! %s%szzzv", vim.v.count1, direction)
local status, msg = pcall(vim.cmd, cmd) local status, msg = pcall(vim.cmd, cmd)
-- Deal with the case that there is no such pattern in current buffer.
if not status then if not status then
-- 13 is the index where real error message starts local start_idx, _ = string.find(msg, 'E486', 1, true)
msg = msg:sub(13) local msg_part = string.sub(msg, start_idx)
api.nvim_err_writeln(msg) api.nvim_err_writeln(msg_part)
return return
end end