Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opens a new tab on every buffer write on Firefox 60.0.1 #84

Open
der-ali opened this issue Jun 14, 2018 · 7 comments
Open

Opens a new tab on every buffer write on Firefox 60.0.1 #84

der-ali opened this issue Jun 14, 2018 · 7 comments

Comments

@der-ali
Copy link

der-ali commented Jun 14, 2018

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
    
@phcerdan
Copy link

Facing this as well.

@jessebett
Copy link

I also have this bug.

@mortang2410
Copy link

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 😏

@drmason13
Copy link

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.

@der-ali
Copy link
Author

der-ali commented Oct 15, 2018

thanks @drmason13 ^^ It worked for me

Amudtogal added a commit to Amudtogal/vim-markdown-preview that referenced this issue Jan 31, 2019
As html with images is rendered into the local folder, the local preview
function is used.

However a ' was missing in the call of `xdotool search`, spawning new
windows with every call (independent of the browser option).

Closes JamshedVesuna#84.
@amirulmenjeni
Copy link

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

@DimiTech
Copy link

DimiTech commented May 1, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants