Skip to content

Commit db4764d

Browse files
phanenibhagwan
authored andcommitted
fix(path): resolve symlink when compare bufname
nvim_buf_get_name/bufname return a resolved version
1 parent 0867870 commit db4764d

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

lua/fzf-lua/path.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ function M.entry_to_file(entry, opts, force_uri)
537537
end
538538
elseif file and #file > 0 then -- get bufnr from give path
539539
local buf = vim.fn.bufnr(file)
540-
if buf ~= -1 and vim.api.nvim_buf_get_name(buf) == file then
540+
if buf ~= -1 and vim.api.nvim_buf_get_name(buf) == (uv.fs_realpath(file) or file) then
541541
bufnr = buf
542542
bufname = file
543543
end

tests/path_spec.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -466,19 +466,19 @@ describe("Testing path module", function()
466466
end)
467467

468468
it("parse loaded path", function()
469-
helpers.SKIP_IF_MAC()
470-
if helpers.IS_WIN() then helpers.SKIP_IF_NOT_NIGHTLY() end
469+
helpers.SKIP_IF_WIN()
471470
local r = {}
472471
vim.cmd [[bwipe]]
473-
vim.cmd.edit("/tmp/foo:bar.txt")
474-
local bufname = "/tmp/foo:bar.txt"
475-
eq(path.entry_to_file("/tmp/foo:bar.txt", r), {
472+
local name = "/tmp/foo:bar.txt"
473+
vim.cmd.edit(name)
474+
vim.cmd([[sil write]])
475+
eq(path.entry_to_file(name, r), {
476476
col = 0,
477477
line = 0,
478-
stripped = bufname,
479-
path = bufname,
478+
stripped = name,
479+
path = name,
480480
bufnr = vim.fn.bufnr(),
481-
bufname = helpers.IS_MAC() and vim.fs.joinpath("/private", bufname) or bufname,
481+
bufname = name,
482482
})
483483
end)
484484
end)

0 commit comments

Comments
 (0)