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'))