( content: string, language: string = "plaintext" )
| 2 | import { getParseTreeApi } from "../util/getExtensionApi"; |
| 3 | |
| 4 | export async function openNewEditor( |
| 5 | content: string, |
| 6 | language: string = "plaintext" |
| 7 | ) { |
| 8 | await vscode.commands.executeCommand("workbench.action.closeAllEditors"); |
| 9 | |
| 10 | const document = await vscode.workspace.openTextDocument({ |
| 11 | language, |
| 12 | content, |
| 13 | }); |
| 14 | |
| 15 | await (await getParseTreeApi()).loadLanguage(language); |
| 16 | |
| 17 | return await vscode.window.showTextDocument(document); |
| 18 | } |
| 19 | |
| 20 | /** |
| 21 | * Open a new notebook editor with the given cells |