| 187 | } |
| 188 | |
| 189 | protected async knitWithProgress(args: IKnitArgs): Promise<DisposableProcess | undefined> { |
| 190 | let childProcess: DisposableProcess | undefined = undefined; |
| 191 | await util.doWithProgress( |
| 192 | (async ( |
| 193 | token: vscode.CancellationToken | undefined, |
| 194 | progress: vscode.Progress<{ |
| 195 | message?: string | undefined; |
| 196 | increment?: number | undefined; |
| 197 | }> | undefined) => { |
| 198 | childProcess = await this.knitDocument(args, token, progress) as DisposableProcess; |
| 199 | }), |
| 200 | vscode.ProgressLocation.Notification, |
| 201 | `Knitting ${args.fileName} ${args.rOutputFormat ? 'to ' + args.rOutputFormat : ''} `, |
| 202 | true |
| 203 | ).catch((rejection: IKnitRejection) => { |
| 204 | if (!rejection.wasCancelled) { |
| 205 | void vscode.window.showErrorMessage('There was an error in knitting the document. Please check the R Markdown output stream.'); |
| 206 | this.rMarkdownOutput.show(true); |
| 207 | } |
| 208 | // this can occur when a successfuly knitted document is later altered (while still being previewed) and subsequently fails to knit |
| 209 | args?.onRejection?.(args.filePath, rejection); |
| 210 | rejection.cp?.dispose(); |
| 211 | }); |
| 212 | return childProcess; |
| 213 | } |
| 214 | } |