Skip to content

Commit 328c2f1

Browse files
authored
fix: executable not being checked properly for absolute paths (#834)
If absolute path was passed, we would return it regardless if it was executable
1 parent 9a98b68 commit 328c2f1

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lua/conform/util.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ M.find_executable = function(paths, default)
1818
for _, path in ipairs(paths) do
1919
local normpath = vim.fs.normalize(path)
2020
local is_absolute = vim.startswith(normpath, "/")
21-
if is_absolute and vim.fn.executable(normpath) then
21+
22+
if is_absolute and vim.fn.executable(normpath) == 1 then
2223
return normpath
2324
end
2425

2526
local idx = normpath:find("/", 1, true)
2627
local dir, subpath
28+
2729
if idx then
2830
dir = normpath:sub(1, idx - 1)
2931
subpath = normpath:sub(idx)
@@ -32,9 +34,11 @@ M.find_executable = function(paths, default)
3234
dir = normpath
3335
subpath = ""
3436
end
37+
3538
local results = vim.fs.find(dir, { upward = true, path = ctx.dirname, limit = math.huge })
3639
for _, result in ipairs(results) do
3740
local fullpath = result .. subpath
41+
3842
if vim.fn.executable(fullpath) == 1 then
3943
return fullpath
4044
end

0 commit comments

Comments
 (0)