From 1ce5eaad7ada8627910d32a1a2daab184e6419e6 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 3 Sep 2020 11:59:51 -0400 Subject: fix: Prevent people from erroring from having new lines in display --- lua/telescope/pickers.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lua/telescope/pickers.lua') diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index b072f90..ec515c4 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -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 )) -- cgit v1.2.3