vim-markdown-preview
vim-markdown-preview copied to clipboard
Opens a new tab on every buffer write on Firefox 60.0.1
The Plugin opens a new tab on every write instead of reloading the existing one
-
Ubuntu 18.04
-
Firefox 60.0.1
-
Vim Config:
let vim_markdown_preview_github=1 let vim_markdown_preview_toggle=3
Facing this as well.
I also have this bug.
That is because firefox does not report the filename in its window name, so xdotool can't search for it. For now, only chromium-browser and the like do report the filename. So you either change your xdg-open (if you use that setting), or the see browser. Or just be like me, fork and replace see with chromium-browser :smirk:
I don't know if Firefox used to not share a window name, but now it appears to:
$ firefox --version
Mozilla Firefox 62.0.3
$ xprop | grep 'WM_NAME(STRING)'
{Click on Firefox}
WM_NAME(STRING) = "vim-markdown-preview.html - Mozilla Firefox"
$ xdotool search --name 'vim-markdown-preview.html'
56623121
Changing the browser name option to Mozilla Firefox should make it work :)
let vim_markdown_preview_browser='Mozilla Firefox'
The name is important, as the plugin script searches for the full name of the browser in the window. If it was set to something like 'Firefox' then I don't think it would work.
The relevant plugin code is:
if g:vmp_osname == 'unix'
let chrome_wid = system("xdotool search --name vim-markdown-preview.html - " . g:vim_markdown_preview_browser . "'")
if !chrome_wid
if g:vim_markdown_preview_use_xdg_open == 1
call system('xdg-open vim-markdown-preview.html 1>/dev/null 2>/dev/null &')
else
call system('see vim-markdown-preview.html 1>/dev/null 2>/dev/null &')
endif
else
let curr_wid = system('xdotool getwindowfocus')
call system('xdotool windowmap ' . chrome_wid)
call system('xdotool windowactivate ' . chrome_wid)
call system("xdotool key 'ctrl+r'")
call system('xdotool windowactivate ' . curr_wid)
endif
endif
This makes it always open a new window if it can't find the window using xdotools search.
With the right value of name it will also swap the focus back to vim which is very nice.
thanks @drmason13 ^^ It worked for me
Same here, using qutebrowser, opened with xdg-open.
My settings:
let vim_markdown_preview_use_xdg_open=1
let vim_markdown_preview_hotkey='<C-m>'
let vim_markdown_preview_toggle=2 " display on buffer write
I had the same issue as OP, and changing the browser name to 'Mozilla Firefox' made it so that the tab doesn't even open at all. I'm on MacOS 10.15.4, Grip 4.5.2.