vim-markdown-preview icon indicating copy to clipboard operation
vim-markdown-preview copied to clipboard

Opens a new tab on every buffer write on Firefox 60.0.1

Open der-ali opened this issue 7 years ago • 7 comments

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
    

der-ali avatar Jun 14 '18 14:06 der-ali

Facing this as well.

phcerdan avatar Jul 23 '18 14:07 phcerdan

I also have this bug.

jessebett avatar Sep 14 '18 16:09 jessebett

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:

mortang2410 avatar Oct 08 '18 00:10 mortang2410

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.

drmason13 avatar Oct 14 '18 10:10 drmason13

thanks @drmason13 ^^ It worked for me

der-ali avatar Oct 15 '18 09:10 der-ali

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

amirulmenjeni avatar Nov 26 '19 06:11 amirulmenjeni

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.

DimiTech avatar May 01 '20 20:05 DimiTech