55
66import * as _path from 'path'
77import * as vscode from 'vscode'
8- import { getTabSizeSetting } from './editorUtilities'
8+ import { disposeOnEditorClose , getTabSizeSetting } from './editorUtilities'
99import { tempDirPath } from '../filesystemUtilities'
1010import { getLogger } from '../logger'
1111import 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