fix: Prevent people from erroring from having new lines in display

This commit is contained in:
TJ DeVries
2020-09-03 11:59:51 -04:00
parent b04ec331c4
commit 1ce5eaad7a
2 changed files with 23 additions and 1 deletions

View File

@@ -259,7 +259,14 @@ function Picker:find()
display = ' ' .. display
-- log.info("Setting row", row, "with value", entry)
vim.api.nvim_buf_set_lines(results_bufnr, row, row + 1, false, {display})
local set_ok = pcall(vim.api.nvim_buf_set_lines, results_bufnr, row, row + 1, false, {display})
-- This pretty much only fails when people leave newlines in their results.
-- So we'll clean it up for them if it fails.
if not set_ok then
display = display:gsub("\n", " | ")
vim.api.nvim_buf_set_lines(results_bufnr, row, row + 1, false, {display})
end
end
))