Environment:
gvim 8.0.45 64bit on windows 10.
netrw v162h
Description:
gx (|netrw-gx|) on an url downloaded the file using curl instead of bringing up the url in a browser.
In addition, I didn't set g:netrw_gx and g:netrw_browsex_viewer.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
Please try the directions in :help netrw-debug. I don't have a windows 10 system myself to work with.
cecamp commented 7 hours ago
Please try the directions in :help netrw-debug. I don't have a windows 10 system myself to work with.
FYI, I tested also on the pc of my work, which is a windows 7. The same problem there. I will try the debug later.
@cecamp I have tried netrw-debug.
I activated Decho and I found the problem is from netrw.
Actually, gx in visual mode did bring up the url in browser. Then I compared the debug information between gx in normal mode and visual mode.
In visual mode:
netrw#BrowseXVis calls netrw#CheckIfRemote without parameter, making remote=0. As a result, fname is assigned by a:fname, which is the URL.
In normal mode:
On the contrary, netrw#CheckIfRemote is called with parameter, making remote=1. In consequence, netrw#BrowseX creates a local copy (netrw.vim 162j :5087), making fname is renamed by a tmp file.
Solution
The simple solution is to remove the parameter of CheckIfRemote at line 84 in file netrwPlugin.vim.
Debug info
I paste below the debug information when url http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/ is clicked.
netrw#CheckIfRemote() a:0=1 { |curfile<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> |return netrw#CheckIfRemote 1 } netrw#BrowseX(fname<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> remote=1) { |remote: a:remote=1: create a local copy of <http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> ~53 |basename<chez-syl> ~59 |newname <C:/Users/cxi/AppData/Local/Temp/chez-syl.tmp> ~60 |newname=C:/Users/cxi/AppData/Local/Temp/chez-syl.tmp |fname<C:/Users/cxi/AppData/Local/Temp/chez-syl.tmp> ~79 |exten<fr/2012/03/bonnes-pratiques-jquery/> netrwFileHandlers#NFH_fr/2012/03/bonnes-pratiques-jquery/():exists=0 ~80 |windows ~134 |return netrw#BrowseX }
netrw#BrowseXVis() { |@@<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> ~4 |netrw#CheckIfRemote() a:0=0 { ||curfile<Git_repo/tabcdn_simulmo/README.md> ||return netrw#CheckIfRemote 0 } |netrw#BrowseX(fname<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> remote=0) { ||fname<http://chez-syl.fr/2012/03/bonnes-pratiques-jquery/> ~79 ||exten<fr/2012/03/bonnes-pratiques-jquery/> netrwFileHandlers#NFH_fr/2012/03/bonnes-pratiques-jquery/():exists=0 ~80 ||windows ~134 ||return netrw#BrowseX } |return netrw#BrowseXVis }
News on version v162k:
gx(visual) now works the same way as gx(normal). So gx(visual) does not either bring URL in a browser if your highlight an URL like http://xxx.
This is because the function netrw#BrowseXVis, which is executed by gx(visual), is slightly modified in v162k:
" See file vimfiles/autoload/netrw.vim:5327 call netrw#BrowseX(@@,netrw#CheckIfRemote(@@))
which was called without parameter in previous version:
call netrw#BrowseX(@@,netrw#CheckIfRemote())
That's because the "without parameter" call was incorrect.
I agree with you. And I think gx is meant to handler other url-like string such as ftp, scp, etc as well.
You should get a message: error not a netrw-style url; netrw uses
protocol://[user@]hostname[:port]/[path])
I didn't get this error message but some bizarre split window behavior . This is another story about netrw#ErrorMsg() not working correctly. Nevertheless, this message should have been printed.
gx is intended to handle urls like http://xxx.whatever/ (note that
trailing slash), and it needs to know whether the call is local or remote.
The question is how netrw should handle a http(s):// string. The actual behavior on win10 is that it considers http(s):// a remote call, then downloads the web page, renames it as xxxx.tmp and tries to open this tmp file. But this behavior does not make any sense. While, if http(s):// is seen as local, then it can be directly handled by a browser and I think that makes sense.
I think some finer condition test should be written inside the netrw#BrowseX function.
in Gvim7.4 on Windows, pressing gx over a URL would successfully open Chrome. First I would get a quick cmd window that would disappear and then the browser would open
in Gvim8, I'm seeing the cmd window open and close, and then quickly seeing this error in the Vim command line:
"NetrwMessage" --No lines in buffer--
and then the error disappears and it opens up a horizontal split
I personally use open-browser.vim for this purpose.
I think it is stable and tested well. Moreover, it works on many platforms including macOS, Linux, Windows, etc.
is there a fix to this issue yet?
I just tested the fresh new cygwin install that contains vim8. seem issue and no luck.
will have to try the open-browser.vim plugin...
I'm still getting this issue. I'd love to not have to not install yet another plugin.
I'm willing to help diagnose and code to help fix the issue.
Is there any work around for this other than installing some plugin ?
May be some flag value set in .vimrc
It would help if a volunteer would take the advice in :help netrw-debug . I don't have a Mac and so can't really debug this without such help.
I am still getting this issue. gx does not always open links in the browser. Seems dependent on what file type I'm in.
@jsatk if you want this fixed, follow the advice from #1386 (comment)
closing this in favor of #4738 (which seems to be a duplicate).
Closed #1386.