Skip to content

Commit b18a853

Browse files
committed
add dispose to virtual txt doc
1 parent d28bb18 commit b18a853

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/core/src/shared/utilities/textDocumentUtilities.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as _path from 'path'
77
import * as vscode from 'vscode'
8-
import { getTabSizeSetting } from './editorUtilities'
8+
import { disposeOnEditorClose, getTabSizeSetting } from './editorUtilities'
99
import { tempDirPath } from '../filesystemUtilities'
1010
import { getLogger } from '../logger'
1111
import fs from '../fs/fs'
@@ -247,11 +247,8 @@ class ReadonlyDocument {
247247
private readonly scheme = 'AWStoolkit-readonly'
248248
private readonly provider = new ReadonlyTextDocumentProvider()
249249

250-
constructor() {
251-
vscode.workspace.registerTextDocumentContentProvider(this.scheme, this.provider)
252-
}
253-
254250
public async show(content: string, filename: string) {
251+
const disposableProvider = vscode.workspace.registerTextDocumentContentProvider(this.scheme, this.provider)
255252
this.provider.setContent(content)
256253
const uri = vscode.Uri.parse(`${this.scheme}:/${filename}.txt`)
257254
const options: vscode.TextDocumentShowOptions = {
@@ -263,6 +260,8 @@ class ReadonlyDocument {
263260
// Open the document with the updated content
264261
const document = await vscode.workspace.openTextDocument(uri)
265262
await vscode.window.showTextDocument(document, options)
263+
264+
disposeOnEditorClose(uri, disposableProvider)
266265
}
267266
}
268267

0 commit comments

Comments
 (0)