add tag closing for tsx (for #34484)

This commit is contained in:
Martin Aeschlimann 2021-09-30 11:17:42 +02:00
parent 801dff2f3b
commit ab55b573ea
No known key found for this signature in database
GPG key ID: 2609A01E695523E3
2 changed files with 8 additions and 6 deletions

View file

@ -40,7 +40,6 @@ export function activateTagClosing(tagProvider: (document: TextDocument, positio
}
function onDidChangeTextDocument({ document, contentChanges, reason }: TextDocumentChangeEvent) {
console.log('onDidChangeTextDocument', contentChanges, reason);
if (!isEnabled || contentChanges.length === 0 || reason === TextDocumentChangeReason.Undo || reason === TextDocumentChangeReason.Redo) {
return;
}

View file

@ -24,7 +24,7 @@ class TagClosing extends Disposable {
) {
super();
vscode.workspace.onDidChangeTextDocument(
event => this.onDidChangeTextDocument(event.document, event.contentChanges),
event => this.onDidChangeTextDocument(event),
null,
this._disposables);
}
@ -46,11 +46,14 @@ class TagClosing extends Disposable {
}
private onDidChangeTextDocument(
document: vscode.TextDocument,
changes: readonly vscode.TextDocumentContentChangeEvent[]
{ document, contentChanges, reason }: vscode.TextDocumentChangeEvent
) {
if (contentChanges.length === 0 || reason === vscode.TextDocumentChangeReason.Undo || reason === vscode.TextDocumentChangeReason.Redo) {
return;
}
const activeDocument = vscode.window.activeTextEditor && vscode.window.activeTextEditor.document;
if (document !== activeDocument || changes.length === 0) {
if (document !== activeDocument) {
return;
}
@ -69,7 +72,7 @@ class TagClosing extends Disposable {
this._cancel = undefined;
}
const lastChange = changes[changes.length - 1];
const lastChange = contentChanges[contentChanges.length - 1];
const lastCharacter = lastChange.text[lastChange.text.length - 1];
if (lastChange.rangeLength > 0 || lastCharacter !== '>' && lastCharacter !== '/') {
return;