ternjs / tern_for_vim

Tern plugin for Vim
MIT License
1.83k stars 100 forks source link

Redirect TernDocBrowse output to devnull #92

Closed ghost closed 9 years ago

ghost commented 9 years ago

Whenever I opened the documentation with my browser I ended up receiving the stderr / stdio of Chromium inside vim. This fix temporarily redirects the output to /dev/null.

Before: Before

After using :TernDocBrowse After

Obviously my Chromium has seen better days, but no matter the length of the message it is still annoying: After2

marijnh commented 9 years ago

I agree with the idea, but did you test the os.dup magic on different platforms? That sounds like the kind of thing that will break horribly on Windows (and I don't want to be the one to resolve it if it does).

ghost commented 9 years ago

Sadly I do not have environment setup to test it in its entirety on Windows, but I did running the following script on Windows using both Python 2.7.9 and 3.4.3 without any problems:

import os, webbrowser

savout = os.dup(1)
os.close(1)
os.open(os.devnull, os.O_RDWR)
try:
    webbrowser.open('https://nodejs.org/api/')
finally:
    os.dup2(savout, 1)
marijnh commented 9 years ago

All right. I was also unable to find a less scary-looking solution. I've merged this as 63f7f56