diff options
| author | elianiva <dicha.arkana03@gmail.com> | 2021-01-23 19:35:29 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-23 19:35:29 +0700 |
| commit | 099910dcd922723b2634c74c0958ef4d169721dd (patch) | |
| tree | bfaf4b79159311dc7501885fda91c88b8be4864d /lua/telescope/previewers/buffer_previewer.lua | |
| parent | 223ec81774ae4720d067bb685b0aa38eea761cd0 (diff) | |
fix: escape filename for previewer and action (#456)
Diffstat (limited to 'lua/telescope/previewers/buffer_previewer.lua')
| -rw-r--r-- | lua/telescope/previewers/buffer_previewer.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lua/telescope/previewers/buffer_previewer.lua b/lua/telescope/previewers/buffer_previewer.lua index 7e6fffb..31895a9 100644 --- a/lua/telescope/previewers/buffer_previewer.lua +++ b/lua/telescope/previewers/buffer_previewer.lua @@ -21,13 +21,15 @@ previewers.file_maker = function(filepath, bufnr, opts) local ft = opts.use_ft_detect and pfiletype.detect(filepath) if opts.bufname ~= filepath then - if vim.loop.fs_stat(filepath).type == 'directory' then + filepath = vim.fn.expand(filepath) + local stat = vim.loop.fs_stat(filepath) or {} + if stat.type == 'directory' then pscan.ls_async(filepath, { hidden = true, on_exit = vim.schedule_wrap(function(data) vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, data) if opts.callback then opts.callback(bufnr) end end)}) else - path.read_file_async(vim.fn.expand(filepath), vim.schedule_wrap(function(data) + path.read_file_async(filepath, vim.schedule_wrap(function(data) if not vim.api.nvim_buf_is_valid(bufnr) then return end vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, vim.split(data, '[\r]?\n')) |
