Skip to content

Commit cac2494

Browse files
authored
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.
1 parent 68a6d8e commit cac2494

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lua/telescope/previewers/term_previewer.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ local bat_maker = function(filename, lnum, start, finish)
3737
local command = { "bat" }
3838

3939
if lnum then
40-
table.insert(command, { "--highlight-line", lnum })
40+
vim.list_extend(command, { "--highlight-line", lnum })
4141
end
4242

4343
if has_less then
4444
if start then
45-
table.insert(command, { "--pager", string.format("less -RS +%s", start) })
45+
vim.list_extend(command, { "--pager", string.format("less -RS +%s", start) })
4646
else
47-
table.insert(command, { "--pager", "less -RS" })
47+
vim.list_extend(command, { "--pager", "less -RS" })
4848
end
4949
else
5050
if start and finish then
51-
table.insert(command, { "-r", string.format("%s:%s", start, finish) })
51+
vim.list_extend(command, { "-r", string.format("%s:%s", start, finish) })
5252
end
5353
end
5454

0 commit comments

Comments
 (0)