summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAugust Masquelier <31262046+levouh@users.noreply.github.com>2021-04-17 13:50:07 -0600
committerGitHub <noreply@github.com>2021-04-17 22:50:07 +0300
commitf92b9b1fae70d5fac681a29f0df64549c399f18f (patch)
tree6dbd6604b636e00e1ecab1fbc326762514510d7f
parentd27907b0dac658dfa2fb7e63103675d1832f33e0 (diff)
fix: live_grep path appending with cwd when already absolute (#768)
-rw-r--r--README.md8
-rw-r--r--lua/telescope/builtin/files.lua4
-rw-r--r--lua/telescope/make_entry.lua8
3 files changed, 12 insertions, 8 deletions
diff --git a/README.md b/README.md
index 1a6a5e2..29b28c2 100644
--- a/README.md
+++ b/README.md
@@ -376,10 +376,10 @@ Built-in functions. Ready to be bound to any key you like. :smile:
#### Options for builtin.live_grep
-| Keys | Description | Options |
-|------------------------|-------------------------------------------------------|--------------|
-| `grep_open_files` | Restrict live_grep to currently open files. | boolean |
-| `search_dirs` | List of directories to search in. | list |
+| Keys | Description | Options |
+|------------------------|------------------------------------------------------------------------------------|--------------|
+| `grep_open_files` | Restrict live_grep to currently open files, mutually exclusive with `search_dirs` | boolean |
+| `search_dirs` | List of directories to search in, mutually exclusive with `grep_open_files` | list |
### Vim Pickers
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua
index a30f693..6253545 100644
--- a/lua/telescope/builtin/files.lua
+++ b/lua/telescope/builtin/files.lua
@@ -51,9 +51,7 @@ files.live_grep = function(opts)
local file = vim.api.nvim_buf_get_name(bufnr)
table.insert(filelist, tele_path.make_relative(file, opts.cwd))
end
- end
-
- if search_dirs then
+ elseif search_dirs then
for i, path in ipairs(search_dirs) do
search_dirs[i] = vim.fn.expand(path)
end
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 02d9ca1..8729ebb 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -2,6 +2,8 @@ local entry_display = require('telescope.pickers.entry_display')
local path = require('telescope.path')
local utils = require('telescope.utils')
+local Path = require('plenary.path')
+
local get_default = utils.get_default
local treesitter_type_highlight = {
@@ -155,7 +157,11 @@ do
local execute_keys = {
path = function(t)
- return t.cwd .. path.separator .. t.filename, false
+ if Path:new(t.filename):is_absolute() then
+ return t.filename, false
+ else
+ return t.cwd .. path.separator .. t.filename, false
+ end
end,
filename = function(t)