diff --git a/runtime/pack/dist/opt/nvim.difftool/lua/difftool.lua b/runtime/pack/dist/opt/nvim.difftool/lua/difftool.lua index 1601fafea3..7fb6e70b6b 100644 --- a/runtime/pack/dist/opt/nvim.difftool/lua/difftool.lua +++ b/runtime/pack/dist/opt/nvim.difftool/lua/difftool.lua @@ -123,7 +123,7 @@ local function diff_dirs_diffr(left_dir, right_dir, opt) local qf_entries = {} for _, line in ipairs(lines) do - local modified_left, modified_right = line:match('^Files (.+) and (.+) differ$') + local modified_left, modified_right = line:match("^Files '?(.-)'? and '?(.-)'? differ$") if modified_left and modified_right then local left_exists = vim.fn.filereadable(modified_left) == 1 local right_exists = vim.fn.filereadable(modified_right) == 1 diff --git a/test/functional/plugin/difftool_spec.lua b/test/functional/plugin/difftool_spec.lua index 567376bda3..c1ab1f92f9 100644 --- a/test/functional/plugin/difftool_spec.lua +++ b/test/functional/plugin/difftool_spec.lua @@ -15,8 +15,10 @@ setup(function() n.mkdir_p(testdir_right) t.write_file(testdir_left .. pathsep .. 'file1.txt', 'hello') t.write_file(testdir_left .. pathsep .. 'file2.txt', 'foo') + t.write_file(testdir_left .. pathsep .. 'file4 with space.txt', 'hello') t.write_file(testdir_right .. pathsep .. 'file1.txt', 'hello world') -- modified t.write_file(testdir_right .. pathsep .. 'file3.txt', 'bar') -- added + t.write_file(testdir_right .. pathsep .. 'file4 with space.txt', 'hello world') -- modified end) teardown(function() @@ -42,10 +44,12 @@ describe('nvim.difftool', function() -- file1.txt as modified (M) -- file2.txt as deleted (D) -- file3.txt as added (A) + -- file4 with space.txt as modified (M) eq({ { text = 'M', rel = 'file1.txt' }, { text = 'D', rel = 'file2.txt' }, { text = 'A', rel = 'file3.txt' }, + { text = 'M', rel = 'file4 with space.txt' }, }, entries) end) @@ -83,6 +87,7 @@ describe('nvim.difftool', function() eq({ { text = 'M', rel = 'file1.txt' }, { text = 'A', rel = 'file3.txt' }, + { text = 'M', rel = 'file4 with space.txt' }, }, entries) end) @@ -144,6 +149,7 @@ describe('nvim.difftool', function() { text = 'M', rel = 'file1.txt' }, { text = 'D', rel = 'file2.txt' }, { text = 'A', rel = 'file3.txt' }, + { text = 'M', rel = 'file4 with space.txt' }, }, entries) end) end)