sioyek icon indicating copy to clipboard operation
sioyek copied to clipboard

Inverse search not working on Windows (possible problem in the path file_name)

Open ThunderSmotch opened this issue 2 years ago • 11 comments

Hi!

I've setup Neovim + VimLatex + Sioyek with moderate success, forward search works out of the box.

However, after some debugging on my end, it appears that the inverse search feature is not working. I think it has something to do with the forward slashes present on the .synctex file. When I launch sioyek from the command line with backslashes on the path in the --inverse-search command everything works. If instead I use forward slashes the inverse search stops working.

The file_name variable is the one defined here.

EDIT: This may be relevant code.

ThunderSmotch avatar Dec 06 '22 18:12 ThunderSmotch

Should be (partially) fixed in f57f91806c26cd67830a67e469c6e2632aee8c30. The issue is that synctex returns the path like this:

d:/some/path/file.pdf

While vimtex expects something like this:

D:\some\path\file.pdf

even

d:\some\path\file.pdf

doesn't work. Honestly, I think this is an issue on vimtex's part. I think d:\some\path\file.pdf should be a valid address on windows. For now, as a quick and dirty hack I upper-cased the first letter of the path which should be the drive name but doesn't work if the drive name has more than one letter.

ahrm avatar Dec 06 '22 22:12 ahrm

Thanks!

As a workaround, only setting the option (and not touching on view_method): let g:vimtex_view_general_viewer = 'C:\path_to\sioyek-release-windows\sioyek.exe' Made it work out of the box! Perhaps the issue is indeed on vimtex's implementation of the sioyek view method.

ThunderSmotch avatar Dec 06 '22 23:12 ThunderSmotch

Hi, @ahrm

I tried to config the synctex on sioyek + vscode on Windows. The forward search works perfectly, but I couldn't make the backward search work. The args are set according to https://github.com/ahrm/sioyek/issues/555#issuecomment-1362883291

in vscode:

  "latex-workshop.view.pdf.external.synctex.args": [
    "--inverse-search",
    "\"C:\\Users\\Canoming\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" -r -g %1:%2",
    "--reuse-window",
    "--forward-search-file",
    "%TEX%",
    "--forward-search-line",
    "%LINE%",
    "%PDF%"
  ],

and in prefs_user.config:

inverse_search_command       "C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g %1:%2

I suppose the problem comes from the space in the path, as the backward search succeeded once, but the path was broken into several files at that time. I tried to replace the space with placeholders like %20%, but the backward search completely failed after that. It doesn't work even after I restore all the configs. Is there a way to see the error logs? I tried to call the --inverse-search from CLI, but nothing happened. The debug command from sioyek also did nothing.

Canoming avatar Jan 11 '23 09:01 Canoming

You don't have quotations here:

    "\"C:\\Users\\Canoming\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" -r -g %1:%2",

it should be: ""C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g "%1:%2"",

Same goes for the inverse_search_command, it should be:

inverse_search_command       "C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g "%1:%2"

ahrm avatar Jan 11 '23 10:01 ahrm

You don't have quotations here:

    "\"C:\\Users\\Canoming\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" -r -g %1:%2",

it should be: ""C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g "%1:%2"",

Same goes for the inverse_search_command, it should be:

inverse_search_command       "C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g "%1:%2"

Well, I've tried many different combinations like the ones you provide here

"\"C:\\Users\\Canoming\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" -r -g \"%1:%2\"",
inverse_search_command       "C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g "%1:%2"

But they don't work as well.

Also, in the tutorial.pdf https://github.com/ahrm/sioyek/issues/555#issuecomment-1362883291, there are no quotations on %1:%2, and in the documentation, there are additional arguments

inverse_search_command "C:\path\to\vscode\Code.exe" "C:\path\to\vscode\resources\app\out\cli.js" --ms-enable-electron-run-as-node -r -g "%1:%2"

I'm not sure which one is the latest, but none of them works for me.

Canoming avatar Jan 11 '23 11:01 Canoming

but none of them works for me.

Can you paste your config with quotations here so we can see if there are any issues?

ahrm avatar Jan 11 '23 11:01 ahrm

Can you paste your config with quotations here so we can see if there are any issues?

Actually, the one I wrote above is copied from my config instead of your reply. But to make it clear here is my full config

in the vscode

  "latex-workshop.view.pdf.external.synctex.command": "C:\\Users\\Canoming\\Desktop\\Portable\\sioyek-release-windows\\sioyek.exe",
  "latex-workshop.view.pdf.external.synctex.args": [
    "--inverse-search",
    "\"C:\\Users\\Canoming\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" -r -g \"%1:%2\"",
    "--reuse-window",
    "--forward-search-file",
    "%TEX%",
    "--forward-search-line",
    "%LINE%",
    "%PDF%"
  ],

and in the sioyek, it is

inverse_search_command       "C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g "%1:%2"

Canoming avatar Jan 11 '23 11:01 Canoming

Does this work? :

inverse_search_command       "C:\Users\Canoming\AppData\Local\Programs\Microsoft VS Code\Code.exe" -r -g "%1":%2

ahrm avatar Jan 11 '23 11:01 ahrm

Still, nothing happened. It is very strange, as it worked once. Not sure if it's due to my vscode being auto-updated. Also, in CLI, the sioyek.exe --version doesn't print anything, but sioyek.exe --help works (popup a window). Probably there is something wrong with the stdout

Canoming avatar Jan 11 '23 11:01 Canoming

I'm running into a similar issue. Nothing happens when calling Synctex From Cursor in VS Codium

ejuarezg avatar Mar 02 '23 21:03 ejuarezg

Same issue. Nothing happens when calling Synctex From Cursor in VS Code.

TideDra avatar Sep 04 '23 14:09 TideDra