fix(buffer_previewer): bypass path validation for terminal buffers (#2117)
This commit is contained in:
committed by
GitHub
parent
4725867ec6
commit
787db424e3
@@ -462,13 +462,18 @@ previewers.vimgrep = defaulter(function(opts)
|
|||||||
end,
|
end,
|
||||||
|
|
||||||
define_preview = function(self, entry, status)
|
define_preview = function(self, entry, status)
|
||||||
local p = from_entry.path(entry, true)
|
-- bypass path validation for terminal buffers that don't have appropriate path
|
||||||
if p == nil or p == "" then
|
local has_buftype = vim.api.nvim_buf_get_option(entry.bufnr, "buftype") ~= ""
|
||||||
return
|
local p
|
||||||
|
if not has_buftype then
|
||||||
|
p = from_entry.path(entry, true)
|
||||||
|
if p == nil or p == "" then
|
||||||
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Workaround for unnamed buffer when using builtin.buffer
|
-- Workaround for unnamed buffer when using builtin.buffer
|
||||||
if entry.bufnr and (p == "[No Name]" or vim.api.nvim_buf_get_option(entry.bufnr, "buftype") ~= "") then
|
if entry.bufnr and (p == "[No Name]" or has_buftype) then
|
||||||
local lines = vim.api.nvim_buf_get_lines(entry.bufnr, 0, -1, false)
|
local lines = vim.api.nvim_buf_get_lines(entry.bufnr, 0, -1, false)
|
||||||
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines)
|
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, lines)
|
||||||
jump_to_line(self, self.state.bufnr, entry.lnum)
|
jump_to_line(self, self.state.bufnr, entry.lnum)
|
||||||
|
|||||||
Reference in New Issue
Block a user