Skip to content

Commit 4a7b926

Browse files
authored
Fix executable check in utils.open (#577)
The previous implementation of `utils.open` did not properly check if the necessary executables were present. In Lua, 0 is treated as true, so it always tried to run `xdg-open` even when the executable was not found, preventing the proper command from being executed. This commit updates the check to correctly use the return values of `vim.fn.executable` and `vim.fn.has` functions.
1 parent d9e48c4 commit 4a7b926

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lua/orgmode/utils/init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ function utils.readfile(file, callback, as_string)
4040
end
4141

4242
function utils.open(target)
43-
if vim.fn.executable('xdg-open') then
43+
if vim.fn.executable('xdg-open') == 1 then
4444
return vim.fn.system(string.format('xdg-open %s', target))
4545
end
4646

47-
if vim.fn.executable('open') then
47+
if vim.fn.executable('open') == 1 then
4848
return vim.fn.system(string.format('open %s', target))
4949
end
5050

51-
if vim.fn.has('win32') then
51+
if vim.fn.has('win32') == 1 then
5252
return vim.fn.system(string.format('start "%s"', target))
5353
end
5454
end

0 commit comments

Comments
 (0)