From b7dcf277a7e95a42e50d0b2b63d7201eb3675cf4 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 22 May 2018 10:33:23 -0700 Subject: [PATCH] Make sure we have closed old resources before performing rename --- .../src/features/bufferSyncSupport.ts | 7 +++++-- .../src/features/updatePathsOnRename.ts | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/typescript-language-features/src/features/bufferSyncSupport.ts b/extensions/typescript-language-features/src/features/bufferSyncSupport.ts index 554dfc22d23..b1993914a09 100644 --- a/extensions/typescript-language-features/src/features/bufferSyncSupport.ts +++ b/extensions/typescript-language-features/src/features/bufferSyncSupport.ts @@ -216,8 +216,7 @@ export default class BufferSyncSupport { this.requestDiagnostic(resource); } - private onDidCloseTextDocument(document: TextDocument): void { - const resource = document.uri; + public closeResource(resource: Uri): void { const syncedBuffer = this.syncedBuffers.get(resource); if (!syncedBuffer) { return; @@ -230,6 +229,10 @@ export default class BufferSyncSupport { } } + private onDidCloseTextDocument(document: TextDocument): void { + this.closeResource(document.uri); + } + private onDidChangeTextDocument(e: TextDocumentChangeEvent): void { const syncedBuffer = this.syncedBuffers.get(e.document.uri); if (syncedBuffer) { diff --git a/extensions/typescript-language-features/src/features/updatePathsOnRename.ts b/extensions/typescript-language-features/src/features/updatePathsOnRename.ts index 791baff7567..9ebd2b585d6 100644 --- a/extensions/typescript-language-features/src/features/updatePathsOnRename.ts +++ b/extensions/typescript-language-features/src/features/updatePathsOnRename.ts @@ -71,6 +71,7 @@ export class UpdateImportsOnFileRenameHandler { } // Make sure TS knows about file + this.bufferSyncSupport.closeResource(oldResource); this.bufferSyncSupport.openTextDocument(document); const edits = await this.getEditsForFileRename(document, oldFile, newFile);