From a49d401aefc3cbc2deda0e1a4d1e6022dc01264f Mon Sep 17 00:00:00 2001 From: Randolf Jung Date: Wed, 11 Mar 2026 12:41:58 -0700 Subject: [PATCH 1/2] fix: lower VSCode version --- package.json | 4 ++-- pnpm-lock.yaml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 7100dd8..2b77646 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "https://github.com/mathematic-inc/vscode-pdf.git" }, "engines": { - "vscode": "^1.110.0" + "vscode": "^1.80.0" }, "icon": "icon.png", "license": "Apache-2.0", @@ -117,7 +117,7 @@ "devDependencies": { "@biomejs/biome": "^2.4.6", "@types/node": "^25.4.0", - "@types/vscode": "1.110.0", + "@types/vscode": "1.80.0", "lefthook": "^2.1.3", "tsup": "^8.5.1", "typescript": "^5.9.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cdcb148..0421260 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: ^25.4.0 version: 25.4.0 '@types/vscode': - specifier: 1.110.0 - version: 1.110.0 + specifier: 1.80.0 + version: 1.80.0 lefthook: specifier: ^2.1.3 version: 2.1.3 @@ -408,8 +408,8 @@ packages: '@types/node@25.4.0': resolution: {integrity: sha512-9wLpoeWuBlcbBpOY3XmzSTG3oscB6xjBEEtn+pYXTfhyXhIxC5FsBer2KTopBlvKEiW9l13po9fq+SJY/5lkhw==} - '@types/vscode@1.110.0': - resolution: {integrity: sha512-AGuxUEpU4F4mfuQjxPPaQVyuOMhs+VT/xRok1jiHVBubHK7lBRvCuOMZG0LKUwxncrPorJ5qq/uil3IdZBd5lA==} + '@types/vscode@1.80.0': + resolution: {integrity: sha512-qK/CmOdS2o7ry3k6YqU4zD3R2AYlJfbwBoSbKpBoP+GpXNE+0NEgJOli4n0bm0diK5kfBnchgCEj4igQz/44Hg==} acorn@8.16.0: resolution: {integrity: sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==} @@ -950,7 +950,7 @@ snapshots: dependencies: undici-types: 7.18.2 - '@types/vscode@1.110.0': {} + '@types/vscode@1.80.0': {} acorn@8.16.0: {} From 49808253d709146e57d5bd9facd119da3809e719 Mon Sep 17 00:00:00 2001 From: Randolf Jung Date: Wed, 11 Mar 2026 13:00:28 -0700 Subject: [PATCH 2/2] fix: set loaded=true after open() to prevent overlay manager crash on load Fixes https://github.com/mathematic-inc/vscode-pdf/issues/32 The `loaded` flag was set only after `pdfViewer.pagesPromise` resolved. During that window, post-open initialization (e.g. auto-print detection) can trigger `window.print()`, which calls `ensureOverlay()`. In certain environments this throws "The overlay manager has not yet been initialized." Since `loaded` was still false, the error handler replaced the viewer body and made every PDF appear to fail on load. Fix: move `loaded = true` to immediately after `open()` completes. The PDF is successfully opening at that point; errors during subsequent page rendering are non-fatal, consistent with the original intent of the flag. Co-Authored-By: Claude Sonnet 4.6 --- assets/main.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/main.mjs b/assets/main.mjs index 8f7dd54..4193f6a 100644 --- a/assets/main.mjs +++ b/assets/main.mjs @@ -56,8 +56,8 @@ let loaded = false; void (async () => { await window.PDFViewerApplication.initializedPromise; await window.PDFViewerApplication.open(config); - await window.PDFViewerApplication.pdfViewer.pagesPromise; loaded = true; + await window.PDFViewerApplication.pdfViewer.pagesPromise; const [, hash] = config.url.split("#"); if (hash) { window.PDFViewerApplication.pdfLinkService.setHash( @@ -74,8 +74,8 @@ window.addEventListener("message", async (event) => { case "reload": loaded = false; await window.PDFViewerApplication.open(config); - await window.PDFViewerApplication.pdfViewer.pagesPromise; loaded = true; + await window.PDFViewerApplication.pdfViewer.pagesPromise; window.PDFViewerApplication.pdfViewer.currentPageNumber = Math.min( currentPageNumber, window.PDFViewerApplication.pdfViewer.pagesCount