| 213 | |
| 214 | |
| 215 | export async function saveDocument(document: vscode.TextDocument): Promise<boolean> { |
| 216 | if (document.isUntitled) { |
| 217 | void vscode.window.showErrorMessage('Document is unsaved. Please save and retry running R command.'); |
| 218 | |
| 219 | return false; |
| 220 | } |
| 221 | |
| 222 | const isSaved: boolean = document.isDirty ? (await document.save()) : true; |
| 223 | if (!isSaved) { |
| 224 | void vscode.window.showErrorMessage('Cannot run R command: document could not be saved.'); |
| 225 | } |
| 226 | |
| 227 | return isSaved; |
| 228 | } |
| 229 | |
| 230 | // shows a quick pick asking the user for confirmation |
| 231 | // returns true if the user confirms, false if they cancel or dismiss the quickpick |