From 33a61e38b4b877432840d6ac8101f98ca67739d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 10 Mar 2015 22:37:54 +0100 Subject: [PATCH] Run callbacks only when appropriate (fixes #132) --- autoload/vimtex/view.vim | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/autoload/vimtex/view.vim b/autoload/vimtex/view.vim index 4e650b3..0ad2004 100644 --- a/autoload/vimtex/view.vim +++ b/autoload/vimtex/view.vim @@ -207,10 +207,17 @@ endfunction " }}}2 function! s:mupdf.latexmk_callback() dict " {{{2 - call self.xwin_get_id() - call self.xwin_send_keys(g:vimtex_view_mupdf_send_keys) - call self.forward_search() - call self.focus_vim() + " Try to get xwin ID + if !self.xwin_exists() + call self.xwin_get_id() + endif + + " Some additional callbacks if possible + if self.xwin_exists() + call self.xwin_send_keys(g:vimtex_view_mupdf_send_keys) + call self.forward_search() + call self.focus_vim() + endif endfunction " }}}2 @@ -355,9 +362,16 @@ endfunction " }}}2 function! s:zathura.latexmk_callback() dict " {{{2 - call self.xwin_get_id() - call self.forward_search() - call self.focus_vim() + " Try to get xwin ID + if !self.xwin_exists() + call self.xwin_get_id() + endif + + " Some additional callbacks if possible + if self.xwin_exists() + call self.forward_search() + call self.focus_vim() + endif endfunction " }}}2