Skip to content

Commit

Permalink
Add zathura pid check to connect to correct instance
Browse files Browse the repository at this point in the history
  • Loading branch information
andymass committed Aug 25, 2017
1 parent 8332cb7 commit b25e7b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions autoload/vimtex/view/common.vim
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,13 @@ function! s:xwin_template.xwin_exists() dict " {{{1
" If xwin_id is unset, check if matching viewer windows exist
"
if self.xwin_id == 0
let cmd = 'xdotool search --name ' . fnamemodify(self.out(), ':t')
let result = split(system(cmd), '\n')
if has_key(self, 'get_pid')
let l:cmd = 'xdotool search --all --pid '.self.get_pid()
else
let l:cmd = 'xdotool search'
endif
let l:cmd .= ' --name ' . fnamemodify(self.out(), ':t')
let result = split(system(l:cmd), '\n')
if len(result) > 0
let self.xwin_id = result[-1]
endif
Expand Down
5 changes: 5 additions & 0 deletions autoload/vimtex/view/zathura.vim
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ function! s:zathura.latexmk_append_argument() dict " {{{1
return cmd
endfunction

" }}}1
function! s:zathura.get_pid() dict " {{{1
return str2nr(system('pgrep -nf "^[^ ]*zathura'
\ . '.+--servername\s+'.v:servername.'\s+"')[:-2])
endfunction
" }}}1

" vim: fdm=marker sw=2

0 comments on commit b25e7b8

Please sign in to comment.