summaryrefslogtreecommitdiff
path: root/lua/telescope/from_entry.lua
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2022-08-10 21:47:37 +0200
committerGitHub <noreply@github.com>2022-08-10 21:47:37 +0200
commit8746347ac4065f5795e7bd33c7912ab1152cca4b (patch)
tree51b6fce3bab7c62946103bc8042cafa034f28613 /lua/telescope/from_entry.lua
parent8f80e821085bdb4583e78ea685e68dc34209d360 (diff)
fix: previewer if cwd is not curr dir (#2084)
path needs to be expanded for filereadable and isdirectory
Diffstat (limited to 'lua/telescope/from_entry.lua')
-rw-r--r--lua/telescope/from_entry.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/lua/telescope/from_entry.lua b/lua/telescope/from_entry.lua
index f109efb..486b57c 100644
--- a/lua/telescope/from_entry.lua
+++ b/lua/telescope/from_entry.lua
@@ -25,9 +25,15 @@ function from_entry.path(entry, validate, escape)
end
-- only 0 if neither filereadable nor directory
- local invalid = vim.fn.filereadable(path) + vim.fn.isdirectory(path)
- if validate and invalid == 0 then
- return
+ if validate then
+ -- We need to expand for filereadable and isdirectory
+ -- TODO(conni2461): we are not going to return the expanded path because
+ -- this would lead to cache misses in the perviewer.
+ -- Requires overall refactoring in previewer interface
+ local expanded = vim.fn.expand(path)
+ if (vim.fn.filereadable(expanded) + vim.fn.isdirectory(expanded)) == 0 then
+ return
+ end
end
if escape then
return vim.fn.fnameescape(path)