ahrm / sioyek

Sioyek is a PDF viewer with a focus on textbooks and research papers
https://sioyek.info/
GNU General Public License v3.0
6.75k stars 219 forks source link

[BUG] relative paths with --new-window argument #1065

Open life00 opened 2 months ago

life00 commented 2 months ago

I recently noticed a weird inconsistency when trying to open PDF files as new window with --new-window argument and also supplying the relative path to Sioyek. The problem was that it failed to recognize that relative path correctly.

I identified the reason and I am not completely sure if its a bug or it is on purpose. Here is how you can reproduce it

  1. Lets imagine a scenario where I open a.pdf in directory /files/ as the initial file with the command sioyek --new-window a.pdf (while I am inside /files/) that launches Sioyek.
  2. Then I also want to open b.pdf as another window but it is in directory /files/dir/ to which I previously navigate, so I run sioyek --new-window b.pdf (while being in /files/dir/)

The initial instance of sioyek will be supplied with this new path to file, however it will fail to open it because it is appending the relative path (being ./b.pdf) to the current working directory of the initial instance (being /files/), not the new temporary instance CWD, so it tries to open /files/b.pdf and fails.

The fact that I am still able to open PDF files inside of CWD of initial instance as new window confirms this theory (e.g. I can open c.pdf inside /files/ because it does not trigger the bug).

There is no issue when Sioyek is supplied with the full path to b.pdf, so it is not that critical, however I believe relative paths should still be handled correctly and that's why I report this issue.