mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
add tag closing for tsx (for #34484)
This commit is contained in:
parent
801dff2f3b
commit
ab55b573ea
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue