Skip to content

Commit fde8033

Browse files
committed
ci: normalize windows path
Windows path sep will be normalized into `/` now (by default, was '\'). To align with luv, we normalize the slash again on window (no matter how &shellslash work...)
1 parent 0205711 commit fde8033

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

lua/fzf-lua/path.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@ function M.is_uri(str)
454454
return str:match("^[%a%-]+://") ~= nil
455455
end
456456

457+
-- path seps behavior https://github.com/neovim/neovim/pull/37729
458+
-- luv use `\`, `nvim_buf_get_name` use `/` (on windows, by default)
459+
local buf_get_name = utils.__IS_WINDOWS and
460+
function(buf) return (vim.api.nvim_buf_get_name(buf):gsub([[/]], [[\]])) end
461+
or vim.api.nvim_buf_get_name
462+
457463
---@param entry string
458464
---@param opts fzf-lua.Config|{}?
459465
---@param force_uri boolean?
@@ -566,7 +572,7 @@ function M.entry_to_file(entry, opts, force_uri)
566572
end
567573
elseif file and #file > 0 then -- get bufnr from give path
568574
local buf = vim.fn.bufnr(file)
569-
if buf ~= -1 and vim.api.nvim_buf_get_name(buf) == (uv.fs_realpath(file) or file) then
575+
if buf ~= -1 and buf_get_name(buf) == (uv.fs_realpath(file) or file) then
570576
bufnr = buf
571577
bufname = file
572578
end

tests/path_spec.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,14 @@ describe("Testing path module", function()
393393
col = 2,
394394
})
395395

396-
utils.__IS_WINDOWS = true
397-
eq(path.entry_to_file("C:\\Users\\foo:bar:12:3"), {
398-
col = 3,
399-
line = 12,
400-
path = "C:\\Users\\foo:bar",
401-
stripped = "C:\\Users\\foo:bar:12:3"
402-
})
403-
utils.__IS_WINDOWS = false
396+
if utils.__IS_WINDOWS then
397+
eq(path.entry_to_file("C:\\Users\\foo:bar:12:3"), {
398+
col = 3,
399+
line = 12,
400+
path = "C:\\Users\\foo:bar",
401+
stripped = "C:\\Users\\foo:bar:12:3"
402+
})
403+
end
404404
end)
405405

406406
it("tilde expansion", function()

0 commit comments

Comments
 (0)