diff --git a/package.json b/package.json index 58eacf91..ac6d90c6 100644 --- a/package.json +++ b/package.json @@ -168,6 +168,11 @@ "JPEG image (first slide only)" ] }, + "markdown.marp.exportAutoOpen": { + "type": "boolean", + "default": true, + "description": "Automatically opens the exported file using the default application installed on your operating system." + }, "markdown.marp.mathTypesetting": { "type": "string", "enum": [ diff --git a/src/commands/export.test.ts b/src/commands/export.test.ts index dc933a4b..2e9d1b7d 100644 --- a/src/commands/export.test.ts +++ b/src/commands/export.test.ts @@ -187,6 +187,9 @@ describe('#doExport', () => { it('exports passed document via Marp CLI and opens it', async () => { const runMarpCLI = jest.spyOn(marpCli, 'default').mockImplementation() + setConfiguration({ + 'markdown.marp.exportAutoOpen': true, + }) try { const uri = saveURI() diff --git a/src/commands/export.ts b/src/commands/export.ts index 86bedb7b..4ab96d9b 100644 --- a/src/commands/export.ts +++ b/src/commands/export.ts @@ -193,7 +193,9 @@ export const doExport = async (uri: Uri, document: TextDocument) => { }, ) - if (outputToLocalFS) { + const shouldOpen = marpConfiguration().get('exportAutoOpen')! + + if (outputToLocalFS && shouldOpen) { env.openExternal(uri) } else { const outputUri = Uri.file(outputPath)