summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2022-07-10 21:28:22 +0200
committerGitHub <noreply@github.com>2022-07-10 21:28:22 +0200
commit10a3310546284faae4ada397a61d68e0a8d0d9f7 (patch)
tree27a6c8dd9c848ecb75d993a7cb7fc683abe3db69
parent524c4eb7fb1a9941460ab7c7c09a3bca9cebb7be (diff)
fix: from_entry escape and validation (#2058)
-rw-r--r--lua/telescope/from_entry.lua12
-rw-r--r--lua/telescope/previewers/buffer_previewer.lua8
-rw-r--r--lua/telescope/previewers/term_previewer.lua12
3 files changed, 14 insertions, 18 deletions
diff --git a/lua/telescope/from_entry.lua b/lua/telescope/from_entry.lua
index b608023..f109efb 100644
--- a/lua/telescope/from_entry.lua
+++ b/lua/telescope/from_entry.lua
@@ -12,13 +12,7 @@ local from_entry = {}
function from_entry.path(entry, validate, escape)
escape = vim.F.if_nil(escape, true)
- local path
- if escape then
- path = entry.path and vim.fn.fnameescape(entry.path) or nil
- else
- path = entry.path
- end
-
+ local path = entry.path
if path == nil then
path = entry.filename
end
@@ -35,7 +29,9 @@ function from_entry.path(entry, validate, escape)
if validate and invalid == 0 then
return
end
-
+ if escape then
+ return vim.fn.fnameescape(path)
+ end
return path
end
diff --git a/lua/telescope/previewers/buffer_previewer.lua b/lua/telescope/previewers/buffer_previewer.lua
index 6fdb3e4..f0496ac 100644
--- a/lua/telescope/previewers/buffer_previewer.lua
+++ b/lua/telescope/previewers/buffer_previewer.lua
@@ -415,11 +415,11 @@ previewers.cat = defaulter(function(opts)
return previewers.new_buffer_previewer {
title = "File Preview",
dyn_title = function(_, entry)
- return Path:new(from_entry.path(entry, true)):normalize(cwd)
+ return Path:new(from_entry.path(entry, false, false)):normalize(cwd)
end,
get_buffer_by_name = function(_, entry)
- return from_entry.path(entry, true)
+ return from_entry.path(entry, false)
end,
define_preview = function(self, entry, status)
@@ -454,11 +454,11 @@ previewers.vimgrep = defaulter(function(opts)
return previewers.new_buffer_previewer {
title = "Grep Preview",
dyn_title = function(_, entry)
- return Path:new(from_entry.path(entry, true)):normalize(cwd)
+ return Path:new(from_entry.path(entry, false, false)):normalize(cwd)
end,
get_buffer_by_name = function(_, entry)
- return from_entry.path(entry, true)
+ return from_entry.path(entry, false)
end,
define_preview = function(self, entry, status)
diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua
index 9ba60f8..368f6a9 100644
--- a/lua/telescope/previewers/term_previewer.lua
+++ b/lua/telescope/previewers/term_previewer.lua
@@ -250,11 +250,11 @@ previewers.cat = defaulter(function(opts)
return previewers.new_termopen_previewer {
title = "File Preview",
dyn_title = function(_, entry)
- return Path:new(from_entry.path(entry, true)):normalize(cwd)
+ return Path:new(from_entry.path(entry, false, false)):normalize(cwd)
end,
get_command = function(entry)
- local p = from_entry.path(entry, true)
+ local p = from_entry.path(entry, true, false)
if p == nil or p == "" then
return
end
@@ -273,14 +273,14 @@ previewers.vimgrep = defaulter(function(opts)
return previewers.new_termopen_previewer {
title = "Grep Preview",
dyn_title = function(_, entry)
- return Path:new(from_entry.path(entry, true)):normalize(cwd)
+ return Path:new(from_entry.path(entry, false, false)):normalize(cwd)
end,
get_command = function(entry, status)
local win_id = status.preview_win
local height = vim.api.nvim_win_get_height(win_id)
- local p = from_entry.path(entry, true)
+ local p = from_entry.path(entry, true, false)
if p == nil or p == "" then
return
end
@@ -308,14 +308,14 @@ previewers.qflist = defaulter(function(opts)
return previewers.new_termopen_previewer {
title = "Grep Preview",
dyn_title = function(_, entry)
- return Path:new(from_entry.path(entry, true)):normalize(cwd)
+ return Path:new(from_entry.path(entry, false, false)):normalize(cwd)
end,
get_command = function(entry, status)
local win_id = status.preview_win
local height = vim.api.nvim_win_get_height(win_id)
- local p = from_entry.path(entry, true)
+ local p = from_entry.path(entry, true, false)
if p == nil or p == "" then
return
end