Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(git_status): use -z over --porcelain #3301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lua/telescope/_.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ function LinesPipe:read()
return read_rx()
end

function LinesPipe:iter(schedule)
if schedule == nil then
schedule = true
end
function LinesPipe:iter(schedule, opts)
schedule = vim.F.if_nil(schedule, true)
local split_char = vim.F.if_nil(opts.split_char, "\n")

local text = nil
local index = nil
Expand All @@ -167,8 +166,7 @@ function LinesPipe:iter(schedule)
return (previous or "") .. read
end

local next_value = nil
next_value = function()
local function next_value()
if schedule then
async.util.scheduler()
end
Expand All @@ -178,7 +176,7 @@ function LinesPipe:iter(schedule)
end

local start = index
index = string.find(text, "\n", index, true)
index = string.find(text, split_char, index, true)

if index == nil then
text = get_next_text(string.sub(text, start or 1))
Expand Down
3 changes: 2 additions & 1 deletion lua/telescope/builtin/__git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -369,14 +369,15 @@ git.status = function(opts)
return
end

local args = { "status", "--porcelain=v1", "--", "." }
local args = { "status", "-z", "--", "." }

local gen_new_finder = function()
if vim.F.if_nil(opts.expand_dir, true) then
table.insert(args, #args - 1, "-uall")
end
local git_cmd = git_command(args, opts)
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_git_status(opts))
opts.split_char = "\0"
return finders.new_oneshot_job(git_cmd, opts)
end

Expand Down
1 change: 1 addition & 0 deletions lua/telescope/finders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ finders.new_oneshot_job = function(command_list, opts)

cwd = opts.cwd,
maximum_results = opts.maximum_results,
split_char = opts.split_char,

fn_command = function()
return {
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/finders/async_oneshot_finder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ return function(opts)
process_result(v)
end
end
for line in stdout:iter(false) do
for line in stdout:iter(false, { split_char = opts.split_char }) do
num_results = num_results + 1

if num_results % await_count then
Expand Down
Loading