fix(previewer): check bufnr is not nil (#3410)

This commit is contained in:
Jordan Mandel
2025-02-11 15:01:20 -05:00
committed by GitHub
parent 415af52339
commit 78857db9e8

View File

@@ -545,11 +545,13 @@ previewers.vimgrep = defaulter(function(opts)
local middle_ln = math.floor(lnum + (lnend - lnum) / 2)
pcall(vim.api.nvim_win_set_cursor, self.state.winid, { middle_ln + 1, 0 })
if bufnr ~= nil then
vim.api.nvim_buf_call(bufnr, function()
vim.cmd "norm! zz"
end)
end
end
end
return previewers.new_buffer_previewer {
title = "Grep Preview",