(preview?: RMarkdownPreview)
| 286 | } |
| 287 | |
| 288 | public async updatePreview(preview?: RMarkdownPreview): Promise<void> { |
| 289 | const toUpdate = preview ?? this.activePreview.preview; |
| 290 | const previewUri = toUpdate ? this.previewStore.getFilePath(toUpdate) : undefined; |
| 291 | toUpdate?.cp?.dispose(); |
| 292 | |
| 293 | if (toUpdate && previewUri) { |
| 294 | toUpdate.isRendering = true; |
| 295 | const childProcess: DisposableProcess | void = await this.previewDocument(previewUri, toUpdate.title).catch(() => { |
| 296 | void vscode.window.showErrorMessage('There was an error in knitting the document. Please check the R Markdown output stream.'); |
| 297 | this.rMarkdownOutput.show(true); |
| 298 | this.previewStore.delete(previewUri); |
| 299 | }); |
| 300 | |
| 301 | if (childProcess) { |
| 302 | toUpdate.cp = childProcess; |
| 303 | } |
| 304 | |
| 305 | this.refreshPanel(toUpdate); |
| 306 | toUpdate.isRendering = false; |
| 307 | } |
| 308 | |
| 309 | } |
| 310 | |
| 311 | private async previewDocument(filePath: string, fileName?: string, viewer?: vscode.ViewColumn, currentViewColumn?: vscode.ViewColumn): Promise<DisposableProcess | undefined> { |
| 312 | const knitWorkingDir = this.getKnitDir(knitDir, filePath); |
no test coverage detected