Skip to content

Commit

Permalink
fix(term_preview): bad bat command generation (nvim-telescope#3256)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jamestrew authored Aug 15, 2024
1 parent 68a6d8e commit cac2494
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lua/telescope/previewers/term_previewer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit cac2494

Please sign in to comment.