diff options
| author | Jonas Strittmatter <40792180+smjonas@users.noreply.github.com> | 2023-01-06 12:04:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-06 12:04:15 +0100 |
| commit | b24fdfdb253db3c9e563b372bbdfdb9cd2c6adc8 (patch) | |
| tree | 7dee250544af66cbb191733ab52a840c05887db2 | |
| parent | 0326347eba8103ffd820547f84b75a07bff23256 (diff) | |
fix: correctly parse filenames with special chars in git_status (#2296)
| -rw-r--r-- | lua/telescope/builtin/__git.lua | 4 | ||||
| -rw-r--r-- | lua/telescope/make_entry.lua | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/lua/telescope/builtin/__git.lua b/lua/telescope/builtin/__git.lua index 2228180..737ad26 100644 --- a/lua/telescope/builtin/__git.lua +++ b/lua/telescope/builtin/__git.lua @@ -314,7 +314,7 @@ git.status = function(opts) local gen_new_finder = function() local expand_dir = vim.F.if_nil(opts.expand_dir, true) - local git_cmd = { "git", "status", "-s", "--", "." } + local git_cmd = { "git", "status", "-z", "--", "." } if expand_dir then table.insert(git_cmd, #git_cmd - 1, "-u") @@ -332,7 +332,7 @@ git.status = function(opts) end return finders.new_table { - results = output, + results = vim.split(output[1], " entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_status(opts)), } end diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 362c1b6..ce34ba0 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -1352,7 +1352,13 @@ function make_entry.gen_from_git_status(opts) if entry == "" then return nil end - local mod, file = string.match(entry, "(..).*%s[->%s]?(.+)") + + local mod, file = entry:match "^(..) (.+)$" + -- Ignore entries that are the PATH in XY ORIG_PATH PATH + -- (renamed or copied files) + if not mod then + return nil + end return setmetatable({ value = file, |
