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.
This commit is contained in:
James Trew
2024-08-14 21:44:40 -04:00
committed by GitHub
parent 68a6d8e8a0
commit cac2494a6e

View File

@@ -37,18 +37,18 @@ local bat_maker = function(filename, lnum, start, finish)
local command = { "bat" } local command = { "bat" }
if lnum then if lnum then
table.insert(command, { "--highlight-line", lnum }) vim.list_extend(command, { "--highlight-line", lnum })
end end
if has_less then if has_less then
if start 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 else
table.insert(command, { "--pager", "less -RS" }) vim.list_extend(command, { "--pager", "less -RS" })
end end
else else
if start and finish then 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
end end