-
Notifications
You must be signed in to change notification settings - Fork 407
Changes to SyncTeX backward search #2135
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,10 +72,10 @@ function! vimtex#view#reverse_goto(line, filename) abort " {{{1 | |
| let l:file = resolve(a:filename) | ||
|
|
||
| " Open file if necessary | ||
| if !bufexists(l:file) | ||
| if !bufloaded(l:file) | ||
| if filereadable(l:file) | ||
| try | ||
| execute 'edit' l:file | ||
| execute g:vimtex_view_reverse_search_edit_cmd l:file | ||
| catch | ||
| call vimtex#log#warning("Reverse goto failed") | ||
| return | ||
|
|
@@ -87,11 +87,18 @@ function! vimtex#view#reverse_goto(line, filename) abort " {{{1 | |
| endif | ||
|
|
||
| " Go to correct buffer and line | ||
|
|
||
| " Get buffer number | ||
| let l:bufnr = bufnr(l:file) | ||
| let l:winnr = bufwinnr(l:file) | ||
| execute l:winnr >= 0 | ||
| \ ? l:winnr . 'wincmd w' | ||
| \ : 'buffer ' . l:bufnr | ||
| " Get window and tab numbers | ||
| try | ||
| let [l:winid] = win_findbuf(l:bufnr) | ||
| let [l:tabnr, l:winnr] = win_id2tabwin(l:winid) | ||
| execute l:tabnr . 'tabnext' | ||
| execute l:winnr . 'wincmd w' | ||
| catch | ||
| execute g:vimtex_view_reverse_search_edit_cmd l:file | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get why we need the second
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think so. I included this to replicate the behavior of the old line 94, which used I changed |
||
| endtry | ||
|
|
||
| execute 'normal!' a:line . 'G' | ||
| redraw | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,7 @@ function! s:zathura.latexmk_append_argument() dict abort " {{{1 | |
| if self.has_synctex | ||
| let zathura .= ' -x \"' . g:vimtex_compiler_progname | ||
| \ . ' --servername ' . v:servername | ||
| \ . ' --remote +\%{line} \%{input}\" \%S' | ||
| \ . ' --remote-expr \"\\\"\"vimtex#view#reverse_goto(\%{line}, ''"''"''\%{input}''"''"'')\"\\\"\"\" \%S' | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hahahaha! This makes my day! :D
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And the worst part of this is that it works! Great work!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! I had to do quite a bit of testing with latexmk on the command line. For the record, this is what I used: latexmk -pvc -new-viewer -pdf lectures.tex -e '$pdf_previewer = "zathura -x \"/usr/bin/vim.gtk3 --servername VIM --remote-expr \"\\\"\"vimtex#view#reverse_goto(\%{line}, '"'"'\%{input}'"'"')\"\\\"\"\" lectures.pdf"'The output contained the command line used by latexmk to start Zathura, which I could cross-check against the use of |
||
| endif | ||
|
|
||
| let cmd = vimtex#compiler#latexmk#wrap_option('new_viewer_always', '0') | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would the following code fail? During
tabnext? Orwincmd?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would actually fail in line 95; if the buffer does not exist, then
win_findbufreturns an empty list and the unpacking fails.