Open xiebruce opened 2 years ago
Did you get the LilyPond PDF Preview extension for vscode?
Did you get the LilyPond PDF Preview extension for vscode?
No, I didn't, because I think it's included in VSLilyPond, see here and here
But were you using it?
But were you using it?
I think yes
And I found "LilyPond PDF Preview" has been installed automatically
when I double click on the pdf file that generated by lilypond in vscode, it's opened by the LilyPond PDF Preview plugin
This is strange, on my Mac with 11.6 Big Sur, VSLilyPond 1.60 I can’t reproduce this issue
This is strange, on my Mac with 11.6 Big Sur, VSLilyPond 1.60 I can’t reproduce this issue
Can you try the latest version of vsccode(Version: 1.62.3 (Universal)
) and VSLilyPond(v1.7.3
)? maybe you can reproduce this issue.
Here is my demo, if it is as expected, the pdf will auto reload after I save(compile) the test.ly
right? But it didn't!
Do the other features work like clicking notes to go from pdf to code and from code to pdf?
Do the other features work like clicking notes to go from pdf to code and from code to pdf?
Pdf to code: Yes, it works Code to pdf: No, do I need to hold any key before clicking? Actually I tried hold option, cmd, shift, none of these works.
I forgot that was something from the command pallet (Ctrl + Shift + P): LilyPond PDF Preview: Go to PDF location from Cursor
.
If I open the vscode Output panel and select VSLilyPond: PDF Preview
, when I save a LilyPond file I see this log:
[LOG]: [WEBVIEW]: reload
[LOG]: [WEBVIEW]: pagesinit
[LOG]: [WEBVIEW]: allPagesLoaded
[LOG]: Clearing links for f:\Compositions\Sample01.pdf
[LOG]: Links cleared for f:\Compositions\Sample01.pdf
[LOG]: [WEBVIEW]: Sent clear-links
[LOG]: [WEBVIEW]: Finished handling textedits
[LOG]: [WEBVIEW]: Received link-register-ready
[LOG]: [WEBVIEW]: Finished registering links
I forgot that was something from the command pallet (Ctrl + Shift + P):
LilyPond PDF Preview: Go to PDF location from Cursor
.If I open the vscode Output panel and select
VSLilyPond: PDF Preview
, when I save a LilyPond file I see this log:[LOG]: [WEBVIEW]: reload [LOG]: [WEBVIEW]: pagesinit [LOG]: [WEBVIEW]: allPagesLoaded [LOG]: Clearing links for f:\Compositions\Sample01.pdf [LOG]: Links cleared for f:\Compositions\Sample01.pdf [LOG]: [WEBVIEW]: Sent clear-links [LOG]: [WEBVIEW]: Finished handling textedits [LOG]: [WEBVIEW]: Received link-register-ready [LOG]: [WEBVIEW]: Finished registering links
There's no LilyPond PDF Preview: Go to PDF location from Cursor
option on my vscode
I tried to uninstall and reinstall it, but I can't
You got my instructions backward. It's not VSLilyPond: Go to PDF...
It's LilyPond PDF Preview: Go to PDF location from Cursor
.
Also look in your Output for VSLilyPond: PDF Preview:
You got my instructions backward. It's not
VSLilyPond: Go to PDF...
It'sLilyPond PDF Preview: Go to PDF location from Cursor
.Also look in your Output for VSLilyPond: PDF Preview:
Sorry, I found it, but I can't see any log(including reload log) in the VSLilyPond: PDF Preview
console
And I've tried uninstall all lilypond relative extensions and reinstall vslilypond, still the same, no reloading operations can be found.
@Apostolique @lhl2617 Hi, according to the info I provided above, do you guys know what's happening on my vscode or vslilypond ?
I'm not sure but since it doesn't work you can find any PDF reader that has auto reload for now.
I use SumatraPDF but that's for Windows. I'm sure you can find a similar one for mac.
I'm not sure but since it doesn't work you can find any PDF reader that has auto reload for now.
I use SumatraPDF but that's for Windows. I'm sure you can find a similar one for mac.
Yep, the build-in App "Preview.app" on Mac can do this, but I have to press command+tab
(same as alt+tab
on Win) to see the change.
I'm unable to repro your bug, can you try opening a dev console in VSCode (https://stackoverflow.com/questions/30765782/what-is-the-use-of-the-developer-tools-in-vs-code) and see if anything is wrong there?
@lhl2617
Uncaught (in promise) ReferenceError: Cannot access 'd' before initialization
at pdf.viewer.js:43
I seem to be having the same issue. It had worked for me on Big Sur before. After a completely clean install of VS Code and VSLilypond, the auto-refresh of the PDF preview window (which really uses the LilyPond PDF Preview that comes with VSLilyPond) does not work anymore.
Interestingly, I found a situation that results in the PDF within VSCode to refresh:
Interestingly, I found a situation that results in the PDF within VSCode to refresh:
- Open a lilypond file and its preview within VSCode. Also, open a Preview (the app) window of the PDF.
- Modify the lilypond file and compile it. Right now, neither the VSCode preview nor the Preview should reflect the changes.
- Click on the Preview window. It should refresh and show the changes. After a brief period, the VSCode preview will also refresh and show the changes.
I made a test in your condition, it turns out that the we should switch to another app then switch back to vscode after saving the code, only by doing this, the PDF inside vscode(opened by LilyPond PDF Preview) can reload. This has nothing to do with the macOS app "Preview.app".
I've just tried it with "not Preview.app". Does not work. So far I have only gotten it to work by clicking on Preview.app with the same file.
I have the same problem, and I am using Linux.
Whenever I save, I can see the logs in the Output panel and the PDF is being generated. However, the PDF Preview is not refreshing the output.
I'm having the same problem.
macOS v12.4 Monterey VSCode v1.69.1 (Universal) VSLilyPond v1.7.3 LilyPond PDF Preview v0.2.8 (installed with VSLilyPond)
Switching to Preview.app and back updates the PDF both in Preview.app and in LilyPond PDF Viewer. Switching to an app other than Preview.app doesn't seem to trigger the reload. I also tried opening the PDF (after saving/compiling) with QuickLook (pressing Space bar on macOS in the Finder). QuickLook showed me the updated PDF, but neither Preview.app nor LilyPond PDF Viewer updated (until focusing Preview.app, of course).
Update: I found that LilyPond PDF Viewer will automatically update if it's let sit long enough. In my experience, it's usually less than a minute, but not consistent. I can not consistently replicate this.
Hi @lhl2617 ..thanks for this fantastic plugin !
Locally debugging the PDF Preview Extension, I found that (on Linux) compiling with lilypond will generate a new PDF file (with the same name). Therefore when I created a listener for creation event like this:
this._watcher.onDidCreate((e) => {
if (e.toString() === this.resource.toString()) {
this.reload()
}
})
here https://github.com/lhl2617/VSLilyPond-PDF-preview/blob/master/src/extension/pdf-preview.ts#L62 ..automatical reload works fine !
So this yields the somewhat weird question, if all OS's lilypond command treat PDF compilation the same or different (?)
If you want I can create a PR and try to cover all events
hi folks, I have this bug. I also don't have ready ability to hack on the plugin itself.
so to work around this, I open my console, select "terminal", and on my Fedora linux machine (things may have to be different on OSX) I run this while loop to refresh the pdf each time it gets recreated, which seems to wake up the pdf viewer:
while [ 1 ]; do sleep 1; find . -name "*.pdf" -mmin -0.02 -exec sh -c "echo 'detected changes on {}'; touch {}; sleep 1 " \; ; done;
That will run every second, and it will: 1. run a find for .pdf files that were modified less than .02 minutes ago 2. do a touch 3. the sleep another second per "touch", so that it doesn't keep touching the file over and over again.
I organize that into a script refresh.sh
and just have it wherever my .ly files are.
(noting I just tried lilypond for the first time about an hour ago)
Hi @lhl2617 ..thanks for this fantastic plugin !
Locally debugging the PDF Preview Extension, I found that (on Linux) compiling with lilypond will generate a new PDF file (with the same name). Therefore when I created a listener for creation event like this:
this._watcher.onDidCreate((e) => { if (e.toString() === this.resource.toString()) { this.reload() } })
here https://github.com/lhl2617/VSLilyPond-PDF-preview/blob/master/src/extension/pdf-preview.ts#L62 ..automatical reload works fine !
So this yields the somewhat weird question, if all OS's lilypond command treat PDF compilation the same or different (?)
If you want I can create a PR and try to cover all events
Thank you for offering the solution, I did this on my Mac and it worked!
First of all thank you @lhl2617 for making this possible in the first place! This is my first time venturing in Lilypond territory and I figured it'd be good fit for me given my familiarity with VSCode and TeX. And since I've set this up, I can't even think of going back to GUI based sheet editors.
I realize this is an old issue but I wanted to share a fix that worked for me regarding the auto-reload of the .pdf file. Note that I'm doing this on a MacOS Sonoma 14.5 machine. Shouldn't be too different though on other systems. @clojj and @leiyi-0612 comments were immensely helpful for fixing this 🙏. (I'm pretty much repeating @leiyi-0612 instructions step by step)
pdf-preview.js
located at /Users/{username}/.vscode/extensions/lhl2617.lilypond-pdf-preview-0.2.8/out/extension/pdf-preview.js
const watcher = this._register(vscode.workspace.createFileSystemWatcher(resource.fsPath));
this._register(watcher.onDidCreate((e) => {
if (e.toString() === this.resource.toString()) {
this.reload()
}
}));
Extra thoughts: Not an expert on this but my guess as to why onDidChange
isn't working is because the .pdf file is being built from scratch everytime a .ly file is saved. Meaning there's a brief period of time where the file doesn't exist and onDidChange
can't locate it(??)
I was able to compile the
test.ly
by pressingcommand+s
on my Mac and it generate atest.pdf
file, I open this pdf file in a split window on vscode.As you known, we need to repeat this procedure: write code→save(compile)→preview, but I can't do this, every time I save(compile) the
test.ly
file, thetest.pdf
file not auto reloading, I have to close it and reopen to see the change.How can I solve this problem?
vslilypond
vscode
macOS