summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorelianiva <dicha.arkana03@gmail.com>2021-01-23 19:35:29 +0700
committerGitHub <noreply@github.com>2021-01-23 19:35:29 +0700
commit099910dcd922723b2634c74c0958ef4d169721dd (patch)
treebfaf4b79159311dc7501885fda91c88b8be4864d /lua
parent223ec81774ae4720d067bb685b0aa38eea761cd0 (diff)
fix: escape filename for previewer and action (#456)
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/actions/init.lua2
-rw-r--r--lua/telescope/previewers/buffer_previewer.lua6
2 files changed, 5 insertions, 3 deletions
diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua
index f4c3b08..50c7f37 100644
--- a/lua/telescope/actions/init.lua
+++ b/lua/telescope/actions/init.lua
@@ -120,7 +120,7 @@ function actions._goto_file_selection(prompt_bufnr, command)
vim.cmd(string.format(":tab sb %d", entry_bufnr))
end
else
- filename = path.normalize(filename, vim.fn.getcwd())
+ filename = path.normalize(vim.fn.fnameescape(filename), vim.fn.getcwd())
local bufnr = vim.api.nvim_get_current_buf()
if filename ~= vim.api.nvim_buf_get_name(bufnr) then
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'))