Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add configuration to open exported file by system default app #636

Merged
merged 3 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions editors/vscode/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ Set the print width for the formatter, which is a **soft limit** of characters p
- **Type**: `number`
- **Default**: `120`

## `tinymist.showExportFileIn`

Configures way of opening exported files, e.g. inside of editor tabs or using system application.


## `tinymist.dragAndDrop`

Whether to handle drag-and-drop of resources into the editing typst document.
Whether to handle drag-and-drop of resources into the editing typst document. Note: restarting the editor is required to change this setting.

- **Type**: `boolean`
- **Type**: `string`
- **Enum**:
- `enable`
- `disable`
Expand Down
19 changes: 19 additions & 0 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,25 @@
"type": "number",
"default": 120
},
"tinymist.showExportFileIn": {
"title": "(Experimental) Show Exported Files in Some Place",
"description": "Configures way of opening exported files, e.g. inside of editor tabs or using system application.",
"anyOf": [
{
"type": "string",
"description": "For all kind of files.",
"enum": [
"editorTab",
"systemDefault"
],
"default": "editorTab",
"enumDescriptions": [
"Show the exported files in editor tabs.",
"Show the exported files by system default application."
]
}
]
},
"tinymist.dragAndDrop": {
"title": "Drag and drop",
"description": "Whether to handle drag-and-drop of resources into the editing typst document. Note: restarting the editor is required to change this setting.",
Expand Down
21 changes: 16 additions & 5 deletions editors/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,22 @@ async function commandShow(kind: "Pdf" | "Svg" | "Png", extraOpts?: any): Promis
}
}

// here we can be sure that the pdf exists
await commands.executeCommand("vscode.open", exportUri, {
viewColumn: ViewColumn.Beside,
preserveFocus: true,
} as vscode.TextDocumentShowOptions);
const conf = vscode.workspace.getConfiguration("tinymist");
const openIn: string = conf.get("showExportFileIn", "editorTab");

switch (openIn) {
default:
case "editorTab":
// here we can be sure that the pdf exists
await commands.executeCommand("vscode.open", exportUri, {
viewColumn: ViewColumn.Beside,
preserveFocus: true,
} as vscode.TextDocumentShowOptions);
break;
case "systemDefault":
await vscode.env.openExternal(exportUri);
break;
}
}

export interface PreviewResult {
Expand Down
Loading