izuzak / atom-pdf-view

Support for viewing PDF files in Atom.
https://atom.io/packages/pdf-view
MIT License
106 stars 30 forks source link

Do nothing if pdf.js throws an error #118

Closed 314eter closed 8 years ago

izuzak commented 8 years ago

Thanks for submitting a PR! I'd like to get a better understanding of 1) what problem you're observing (and try to reproduce it), and 2) how this change fixes the problem. For 1), please see my comment in https://github.com/izuzak/atom-pdf-view/issues/117#issuecomment-183679640. For 2), I'd be interested to hear more about that here. Being as clear and as precise as possible would be helpful.

314eter commented 8 years ago

When a pdf file is updated, updatePDF starts with removing the current canvases, and only then tries to open the updated file. If the new file is empty or only partially build, PDFJS.getDocument throws an error, which is catched with finishUpdate. Result: the view is empty, and position and zoom-level are reset.

This can be solved by only removing the current canvases if the pdf is read succesfully by pdf.js. This ensures that a pdf stays visible when it is rebuild, and keeps it position.

izuzak commented 8 years ago

Thanks for explaining, @314eter :bow: -- I was able to reproduce the problem with your detailed instructions in the issue.

Thanks for catching and fixing this :zap: