Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

xdg-open doesn't work inside gvim #172

Closed
aripollak opened this Issue · 11 comments

3 participants

@aripollak

I was able to reproduce my :!xdg-open problem again, but only inside gvim. It seems to work fine if I do :!xdg-open URL &, though I don't know why. This was the only thing I could find about it:
http://superuser.com/questions/386646/xdg-open-url-doesnt-open-the-website-in-my-default-browser

@tpope
Owner

Does call netrw#NetrwBrowseX('http://google.com', 0) work for you? I think it might be easier to just leverage that.

@aripollak

Nope, that doesn't seem to do anything either.

@tpope
Owner

Can you try throwing a ; sleep 5 on the end and see if that fixes it? I'm wondering if this is a very different manifestation of tpope/vim-fugitive#351.

Also, remind me your original solution?

@aripollak

Adding the sleep does fix the problem as well.
It's been a long time, but I believe the problem is related to #166 and OpenURL.

I'm guessing this has to do with the fact that xdg-open calls gvfs-open, and gvfs-open exits immediately, before the underlying browser command is executed, though I'm not sure why that would matter. By contrast, sensible-browser does not exit immediately.

ari@ari:~$ xdg-open http://google.com
ari@ari:~$ Created new window in existing browser session.

ari@ari:~$ sensible-browser http://google.com
Created new window in existing browser session.
ari@ari:~$ 
@aripollak

It does seem likely that it's another manifestation of that vim-fugitive issue.

@tpope
Owner

Yeah I remember the original issue, but you initially submitted a different patch that has since vanished.

@aripollak

I think I had been using sh -c 'xdg-open ...', but that doesn't seem to work now.

@tpope
Owner

Let me know if you figure it out; I want to try to dissect and generalize it.

@WChargin

I've also been having problems with !xdg-open [...] or !gnome-open [...] in gvim, and appending & works fine for me too. This is a problem when using Netrw, though—I should be able to press x on a file and have it open, but this doesn't work, and (AFAIK) I can't change how Netrw executes files. (I can change the command, but not make it background.) Thoughts, workarounds?

@aripollak

Any reason not to just add the & to the xdg-open command? The underlying issue seems to be that gnome-open or gvfs-open, called by xdg-open, backgrounds itself but GVim closes its fake terminal before gnome-open can finish its business.

@tpope
Owner

I'd actually like to switch to delegating to netrw and wash my hands of the matter, but in the meantime, I'd merge a pull request and see if it helps.

@aripollak aripollak referenced this issue from a commit
@aripollak aripollak Launch xdg-open in the background
Fixes #172. Works around not working inside GVim.
3ea8efb
@tpope tpope closed this in #413
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.