io.popen call to curl pollutes the buffer when it fails
sidequestboy opened this issue · 3 comments
Hi thanks for the plugin! I'm trying this out on macos, and encountered
when switching buffers from my obsidian vault. The problem was related to spaces in my filenames, which is what #1 is about.
This issue is about not handling the subprocess stdio streams.
Using lua's native io.popen
for the curl
call sends stderr to the cursor position I believe, as described in this open neovim issue
Fixing the issue might be a simple as appending >/dev/null 2>&1
to the popen
call instead of >/dev/null
, but perhaps it would be good to look at plenary.nvim's Job for async subprocess handling (seems simple), or uv.spawn()
(more complex).
I actually did give this a shot today using both of those methods though, and neither actually worked properly - I'm not sure what I was missing, but I could share that code in another PR if you're interested.
Thank you for the thorough investigation! With uriencoding being added with 6368d1b (or similar) I think it'd be interesting to see another scenario that results in buffer pollution to understand if it's worth fixing. Perhaps another alternative would be to try out plenary's curl wrapper https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/curl.lua.
oh that might be a good solution, also I noticed that wrapper includes a urlencode function as a bonus! Also, as far as neovim dependencies go, plenary is fairly ubiquitous already.
epwalsh/obsidian.nvim already depends on plenary in particular