mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2025-02-18 21:47:12 +00:00
Handle files with spaces
This commit is contained in:
parent
5593754623
commit
716b4d4bb7
@ -27,13 +27,14 @@ function M.file_info(file, toplevel)
|
||||
},
|
||||
cwd = toplevel,
|
||||
on_stdout = function(_, line)
|
||||
local parts = vim.split(line, '%s+')
|
||||
local parts = vim.split(line, '\t')
|
||||
if #parts > 1 then
|
||||
stage = tonumber(parts[3])
|
||||
relpath = parts[2]
|
||||
local attrs = vim.split(parts[1], '%s+')
|
||||
stage = tonumber(attrs[3])
|
||||
if stage <= 1 then
|
||||
mode_bits = parts[1]
|
||||
object_name = parts[2]
|
||||
relpath = parts[4]
|
||||
mode_bits = attrs[1]
|
||||
object_name = attrs[2]
|
||||
else
|
||||
has_conflict = true
|
||||
end
|
||||
@ -41,7 +42,7 @@ function M.file_info(file, toplevel)
|
||||
relpath = parts[1]
|
||||
end
|
||||
end,
|
||||
on_exit = function(_, _)
|
||||
on_exit = function()
|
||||
callback(relpath, object_name, mode_bits, has_conflict)
|
||||
end,
|
||||
})
|
||||
|
@ -27,21 +27,22 @@ function M.file_info(file: string, toplevel: string): cb_function
|
||||
},
|
||||
cwd = toplevel,
|
||||
on_stdout = function(_, line: string)
|
||||
local parts = vim.split(line, '%s+')
|
||||
if #parts > 1 then
|
||||
stage = tonumber(parts[3])
|
||||
local parts = vim.split(line, '\t')
|
||||
if #parts > 1 then -- tracked file
|
||||
relpath = parts[2]
|
||||
local attrs = vim.split(parts[1], '%s+')
|
||||
stage = tonumber(attrs[3])
|
||||
if stage <= 1 then
|
||||
mode_bits = parts[1]
|
||||
object_name = parts[2]
|
||||
relpath = parts[4]
|
||||
mode_bits = attrs[1]
|
||||
object_name = attrs[2]
|
||||
else
|
||||
has_conflict = true
|
||||
end
|
||||
else
|
||||
else -- untracked file
|
||||
relpath = parts[1]
|
||||
end
|
||||
end,
|
||||
on_exit = function(_, _)
|
||||
on_exit = function()
|
||||
callback(relpath, object_name, mode_bits, has_conflict)
|
||||
end
|
||||
}
|
||||
|
@ -730,6 +730,41 @@ local function testsuite(variant, advanced_features)
|
||||
|
||||
end)
|
||||
|
||||
it('handle files with spaces', function()
|
||||
screen:try_resize(20,6)
|
||||
exec_lua('gs.setup(...)', test_config)
|
||||
command("set signcolumn=yes")
|
||||
|
||||
local spacefile = scratch..'/a b c d'
|
||||
|
||||
write_to_file(spacefile, {'spaces', 'in', 'file'})
|
||||
|
||||
edit(spacefile)
|
||||
|
||||
screen:expect{grid=[[
|
||||
{3:+ }^spaces |
|
||||
{3:+ }in |
|
||||
{3:+ }file |
|
||||
{6:~ }|
|
||||
{6:~ }|
|
||||
|
|
||||
]]}
|
||||
|
||||
git{'add', spacefile}
|
||||
sleep(100)
|
||||
edit(spacefile)
|
||||
|
||||
screen:expect{grid=[[
|
||||
{1: }^spaces |
|
||||
{1: }in |
|
||||
{1: }file |
|
||||
{6:~ }|
|
||||
{6:~ }|
|
||||
|
|
||||
]]}
|
||||
|
||||
end)
|
||||
|
||||
end)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user