Skip to content

Commit f9a74a4

Browse files
authored
Run viewer asynchronously using vim.system (#873)
Previously, when the viewer opened, the editor was blocked until the user closes the viewer. Now, the viewer opens asynchronously (using `vim.system` rather than the old `vim.fn.system`); in this way, the user can view the PDF while continuing editing the org file in the editor.
1 parent fa5f3d9 commit f9a74a4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/orgmode/utils/init.lua

+6-3
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,18 @@ end
9393

9494
function utils.open(target)
9595
if vim.fn.executable('xdg-open') == 1 then
96-
return vim.fn.system(string.format('xdg-open %s', target))
96+
vim.system({ 'xdg-open', target }, { text = false })
97+
return 0
9798
end
9899

99100
if vim.fn.executable('open') == 1 then
100-
return vim.fn.system(string.format('open %s', target))
101+
vim.system({ 'open', target }, { text = false })
102+
return 0
101103
end
102104

103105
if vim.fn.has('win32') == 1 then
104-
return vim.fn.system(string.format('start "%s"', target))
106+
vim.system({ 'start', target }, { text = false })
107+
return 0
105108
end
106109
end
107110

0 commit comments

Comments
 (0)