diff --git a/extensions/typescript-language-features/src/features/tagClosing.ts b/extensions/typescript-language-features/src/features/tagClosing.ts index e4df1264ccf..34ddd2c0285 100644 --- a/extensions/typescript-language-features/src/features/tagClosing.ts +++ b/extensions/typescript-language-features/src/features/tagClosing.ts @@ -144,6 +144,7 @@ export class ActiveDocumentDependentRegistration extends Disposable { super(); this._registration = this._register(new ConditionalRegistration(register)); vscode.window.onDidChangeActiveTextEditor(this.update, this, this._disposables); + vscode.workspace.onDidOpenTextDocument(this.onDidOpenDocument, this, this._disposables); this.update(); } @@ -152,6 +153,13 @@ export class ActiveDocumentDependentRegistration extends Disposable { const enabled = !!(editor && vscode.languages.match(this.selector, editor.document)); this._registration.update(enabled); } + + private onDidOpenDocument(openedDocument: vscode.TextDocument) { + if (vscode.window.activeTextEditor && vscode.window.activeTextEditor.document === openedDocument) { + // The active document's language may have changed + this.update(); + } + } } export function register(