Skip to content

Commit a3bdde1

Browse files
committed
Remove worksheets when closed
1 parent 701e8ea commit a3bdde1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

vscode-dotty/src/extension.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export function activate(context: ExtensionContext) {
3636
vscode.commands.executeCommand(worksheet.worksheetEvaluateAfterSaveKey)
3737
}
3838
})
39+
vscode.workspace.onDidCloseTextDocument(document => {
40+
if (worksheet.isWorksheet(document)) {
41+
worksheet.removeWorksheet(document)
42+
}
43+
})
3944

4045
vscode.commands.registerCommand(worksheet.worksheetEvaluateAfterSaveKey, () => {
4146
worksheet.evaluateCommand()

vscode-dotty/src/worksheet.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export const worksheetEvaluateAfterSaveKey = "worksheet.evaluateAfterSave"
5555
*/
5656
export const worksheetCancelEvaluationKey = "worksheet.cancel"
5757

58+
/** Remove the worksheet corresponding to the given document. */
59+
export function removeWorksheet(document: vscode.TextDocument) {
60+
worksheets.delete(document)
61+
}
62+
5863
/** Is this document a worksheet? */
5964
export function isWorksheet(document: vscode.TextDocument): boolean {
6065
return document.fileName.endsWith(".sc")

0 commit comments

Comments
 (0)