From cac2494a6e558f3a21952d3f8becc348876580c6 Mon Sep 17 00:00:00 2001 From: James Trew <66286082+jamestrew@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:44:40 -0400 Subject: [PATCH] fix(term_preview): bad `bat` command generation (#3256) Using `bat` would result in the command being a nested list. eg. using `:Telescope plaents` with `bat` installed ``` { "bat", { "--pager", "less -RS" }, "--style=plain", "--color=always", "--paging=always", "--", "/home/jt/projects/telescope.nvim/data/memes/planets/earth", } ``` This would cause `vim.fn.termopen` to throw an error as the command is expected to be a flat list or string. --- lua/telescope/previewers/term_previewer.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index da7d451..56e5608 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -37,18 +37,18 @@ local bat_maker = function(filename, lnum, start, finish) local command = { "bat" } if lnum then - table.insert(command, { "--highlight-line", lnum }) + vim.list_extend(command, { "--highlight-line", lnum }) end if has_less then if start then - table.insert(command, { "--pager", string.format("less -RS +%s", start) }) + vim.list_extend(command, { "--pager", string.format("less -RS +%s", start) }) else - table.insert(command, { "--pager", "less -RS" }) + vim.list_extend(command, { "--pager", "less -RS" }) end else if start and finish then - table.insert(command, { "-r", string.format("%s:%s", start, finish) }) + vim.list_extend(command, { "-r", string.format("%s:%s", start, finish) }) end end