From 17fa124360a22a944c07975ec9a7aeb020421008 Mon Sep 17 00:00:00 2001 From: DABH Date: Sat, 29 Aug 2026 11:00:20 -0500 Subject: [PATCH 1/2] Declare PostScript Language as extension dependency; clarify docs The preview button is gated on 'resourceLangId == postscript' and the extension activates only 'onLanguage:postscript', but nothing in this extension registers the postscript language for .ps/.eps files - that comes from mxschmitt.postscript. Without it, .eps/.ps files open as plain text, so the preview button never appears and the extension never activates. The README listed the language extension only 'for syntax highlighting', which reads as optional. - package.json: add extensionDependencies so VS Code installs mxschmitt.postscript automatically with this extension - README: state the dependency is required for the preview button, and add a troubleshooting note for the no-button symptom --- README.md | 4 +++- package.json | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a4e6b91..c84ce23 100644 --- a/README.md +++ b/README.md @@ -40,10 +40,12 @@ This extension requires: -- **[PostScript Language](https://marketplace.visualstudio.com/items?itemName=mxschmitt.postscript)** extension for syntax highlighting +- **[PostScript Language](https://marketplace.visualstudio.com/items?itemName=mxschmitt.postscript)** extension — required for the preview button to appear (it registers `.ps`/`.eps` files as PostScript, which this extension's preview button and activation depend on; it also provides syntax highlighting). Installed automatically alongside this extension. - **GhostScript** (provides `ps2pdf`) - **Poppler** (provides `pdftocairo` and `pdfinfo`) +> **No preview button?** If the preview icon does not appear in the editor title bar, your `.ps`/`.eps` file is likely opening as *Plain Text* (check the language indicator in the status bar). Make sure the [PostScript Language](https://marketplace.visualstudio.com/items?itemName=mxschmitt.postscript) extension is installed and enabled, then reload VS Code. + ### macOS ```bash diff --git a/package.json b/package.json index ba9235c..2e68c00 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,9 @@ "activationEvents": [ "onLanguage:postscript" ], + "extensionDependencies": [ + "mxschmitt.postscript" + ], "main": "./out/extension.js", "contributes": { "commands": [ From fcd476daa9bcef8d988afc49005abc07b1325d1d Mon Sep 17 00:00:00 2001 From: DABH Date: Sat, 29 Aug 2026 19:20:53 -0500 Subject: [PATCH 2/2] Install the PostScript Language dependency into the test instance With extensionDependencies declared, the extension under test cannot activate in the integration-test VS Code instance unless mxschmitt.postscript is installed there, so the activation and command tests fail ("Cannot activate ... depends on unknown extension"). Download the dependency as a VSIX and install it via the test CLI before runTests. Installing by id instead can abort with "Signature verification failed with 'ENOENT'" when the marketplace signature verification tooling is unavailable in the test CLI; installing from a local VSIX file avoids that path. spawnSync uses a shell on Windows because Node refuses to spawn .cmd files directly (CVE-2024-27980). Verified locally from a clean .vscode-test sandbox: 7 passing. --- src/test/runTest.ts | 63 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/src/test/runTest.ts b/src/test/runTest.ts index 81ceb16..ca41f5c 100644 --- a/src/test/runTest.ts +++ b/src/test/runTest.ts @@ -1,5 +1,56 @@ +import * as cp from "child_process"; +import * as fs from "fs"; import * as path from "path"; -import { runTests } from "@vscode/test-electron"; +import { + downloadAndUnzipVSCode, + resolveCliArgsFromVSCodeExecutablePath, + runTests, +} from "@vscode/test-electron"; + +const POSTSCRIPT_LANGUAGE_VSIX_URL = + "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/mxschmitt/vsextensions/postscript/latest/vspackage"; + +/** + * This extension declares an extension dependency on mxschmitt.postscript + * (it registers the `postscript` language for .ps/.eps files), so the + * extension under test cannot activate unless that dependency is present in + * the test instance. Install it from a downloaded VSIX file: installing by id + * can fail in the test CLI when the marketplace signature verification + * tooling is unavailable ("Signature verification failed with 'ENOENT'"). + */ +async function installPostscriptLanguageExtension( + vscodeExecutablePath: string +) { + const vsixPath = path.resolve( + __dirname, + "../../.vscode-test/mxschmitt.postscript.vsix" + ); + const response = await fetch(POSTSCRIPT_LANGUAGE_VSIX_URL); + if (!response.ok) { + throw new Error( + `Failed to download PostScript Language extension: HTTP ${response.status}` + ); + } + fs.mkdirSync(path.dirname(vsixPath), { recursive: true }); + fs.writeFileSync(vsixPath, Buffer.from(await response.arrayBuffer())); + + const [cliPath, ...cliArgs] = + resolveCliArgsFromVSCodeExecutablePath(vscodeExecutablePath); + const result = cp.spawnSync( + cliPath, + [...cliArgs, "--install-extension", vsixPath], + { + encoding: "utf-8", + stdio: "inherit", + shell: process.platform === "win32", + } + ); + if (result.status !== 0) { + throw new Error( + `Failed to install PostScript Language extension (exit code ${result.status})` + ); + } +} async function main() { try { @@ -11,14 +62,20 @@ async function main() { // Passed to --extensionTestsPath const extensionTestsPath = path.resolve(__dirname, "./suite/index"); - // Download VS Code, unzip it and run the integration test + // Download VS Code and install the PostScript Language dependency + // into the test instance before running the tests. + const vscodeExecutablePath = await downloadAndUnzipVSCode(); + await installPostscriptLanguageExtension(vscodeExecutablePath); + + // Run the integration test await runTests({ + vscodeExecutablePath, extensionDevelopmentPath, extensionTestsPath, launchArgs: [extensionDevelopmentPath], }); } catch (err) { - console.error("Failed to run tests"); + console.error("Failed to run tests", err); process.exit(1); } }