Skip to content

Commit

Permalink
Added setting to make env.openExternal optional (#464)
Browse files Browse the repository at this point in the history
* added setting to make auto open after export optional

* ran prettier

* updated with new "exportAutoOpen" config flag

* provide feedback about the export process if the file is not automatically opened

* ran prettier

---------

Co-authored-by: Manuel Kiesel <[email protected]>
  • Loading branch information
rtfmkiesel and Manuel Kiesel authored Jan 23, 2025
1 parent f821bf6 commit 3f63e27
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
3 changes: 3 additions & 0 deletions src/commands/export.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion src/commands/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ export const doExport = async (uri: Uri, document: TextDocument) => {
},
)

if (outputToLocalFS) {
const shouldOpen = marpConfiguration().get<boolean>('exportAutoOpen')!

if (outputToLocalFS && shouldOpen) {
env.openExternal(uri)
} else {
const outputUri = Uri.file(outputPath)
Expand Down

0 comments on commit 3f63e27

Please sign in to comment.