Aerijo / atom-pdf-view-plus

Completely remade PDF viewer in Atom
MIT License
12 stars 0 forks source link

regeneration of open PDF leads to error #1

Closed allefeld closed 4 years ago

allefeld commented 4 years ago

When a (generated) PDF is open in a tab, and that PDF is regenerated, this is what happens:

image

The same does not happen with pdf-view.

In my application, the PDF file is actually deleted before being regenerated.

Aerijo commented 4 years ago

Do you have steps to reproduce? I use this for LaTeX with no issue.

allefeld commented 4 years ago

Steps:

1) open a PDF file in pdf-view-plus 2) delete the PDF file 3) recreate the PDF file

The error message above above appears upon step 2), and does not go away upon step 3)

The same does not happen with pdf-view. But I think the reason is that autoreload doesn't work in that package anyway. Because of that, after recreating the PDF, I trigger a reload explicitly:

pv = await atom.workspace.open(pdfPathname)
pv.updatePdf()

I realize that deleting a file does not mix well with file watching. Is there a way to disable autoreload in your package and to reload programmatically?

allefeld commented 4 years ago

It appears that additionally, after that error appears, the underlying item view object becomes defunct. atom.workspace.open(pdfPathname) does not focus the existing pane item, but makes a new one.

allefeld commented 4 years ago

On further reflection, it is unreasonable to expect pdf-view-plus to watch a file beyond deletion, even though technically that would be possible using fs.watchFile. I fixed the problem on my end. Closing.