Closed TanglingTreats closed 7 months ago
Quick fix for this issue is to check if calculated line position is less than buffer previewer height. If true, call set_extmark.
local col = math.floor((width - strings.strdisplaywidth(lines[2])) / 2)
for i, line in ipairs(lines) do
local line_pos = math.floor(height / 2) - 1 + i
if line_pos <= height
then
vim.api.nvim_buf_set_extmark(
bufnr,
anon_ns,
math.floor(height / 2) - 1 + i,
0,
{ virt_text = { { line, "TelescopePreviewMessage" } }, virt_text_pos = "overlay", virt_text_win_col = col }
)
end
end
Another potential solution is to set preview message at line 0 if height <= 2, else execute loop for lines
Description
An exception is thrown for buffer previewer when encountering unsupported file types e.g. binary files if buffer previewer window is two lines or less
Neovim version
Operating system and version
macOS 14.4
Telescope version / branch / rev
0.1.6
checkhealth telescope
Steps to reproduce
Expected behavior
Buffer previewer should display 'Binary cannot be previewed'
Actual behavior
Error is thrown while message do not fit within the previewer
Minimal config