Ensure renamePending gets reset when operation is complete (#4344)
This commit is contained in:
Родитель
c44c50b50c
Коммит
6c0eaea632
|
@ -1,3 +1,3 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="5" y="8" width="6" height="1" fill="#C5C5C5"/>
|
||||
<path d="M15 8H1V7H15V8Z" fill="#C5C5C5"/>
|
||||
</svg>
|
До Ширина: | Высота: | Размер: 160 B После Ширина: | Высота: | Размер: 147 B |
|
@ -1,3 +1,3 @@
|
|||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect x="5" y="8" width="6" height="1" fill="#424242"/>
|
||||
<path d="M15 8H1V7H15V8Z" fill="#424242"/>
|
||||
</svg>
|
До Ширина: | Высота: | Размер: 160 B После Ширина: | Высота: | Размер: 147 B |
|
@ -286,6 +286,7 @@ let failureMessageShown: boolean = false;
|
|||
|
||||
let referencesRequestPending: boolean = false;
|
||||
let renamePending: boolean = false;
|
||||
let renameRequestsPending: number = 0;
|
||||
let referencesParams: RenameParams | FindAllReferencesParams;
|
||||
|
||||
interface ReferencesCancellationState {
|
||||
|
@ -659,7 +660,7 @@ export class DefaultClient implements Client {
|
|||
});
|
||||
};
|
||||
|
||||
if (referencesRequestPending) {
|
||||
if (referencesRequestPending || (this.client.references.symbolSearchInProgress && !this.client.references.referencesViewFindPending)) {
|
||||
let cancelling: boolean = referencesPendingCancellations.length > 0;
|
||||
referencesPendingCancellations.push({ reject, callback });
|
||||
if (!cancelling) {
|
||||
|
@ -688,6 +689,7 @@ export class DefaultClient implements Client {
|
|||
// VS Code will attempt to issue new rename requests while another is still active.
|
||||
// When we receive another rename request, cancel the one that is in progress.
|
||||
renamePending = true;
|
||||
++renameRequestsPending;
|
||||
return new Promise<vscode.WorkspaceEdit>((resolve, reject) => {
|
||||
let callback: () => void = () => {
|
||||
let params: RenameParams = {
|
||||
|
@ -700,6 +702,9 @@ export class DefaultClient implements Client {
|
|||
// The current request is represented by referencesParams. If a request detects
|
||||
// referencesParams does not match the object used when creating the request, abort it.
|
||||
if (params !== referencesParams) {
|
||||
if (--renameRequestsPending === 0) {
|
||||
renamePending = false;
|
||||
}
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
@ -707,6 +712,7 @@ export class DefaultClient implements Client {
|
|||
this.client.languageClient.sendNotification(RenameNotification, params);
|
||||
this.client.references.setResultsCallback((referencesResult) => {
|
||||
referencesRequestPending = false;
|
||||
--renameRequestsPending;
|
||||
let workspaceEdit: vscode.WorkspaceEdit = new vscode.WorkspaceEdit();
|
||||
let cancelling: boolean = referencesPendingCancellations.length > 0;
|
||||
if (cancelling) {
|
||||
|
@ -719,6 +725,9 @@ export class DefaultClient implements Client {
|
|||
referencesPendingCancellations.pop();
|
||||
pendingCancel.callback();
|
||||
} else {
|
||||
if (renameRequestsPending === 0) {
|
||||
renamePending = false;
|
||||
}
|
||||
// If rename UI Was cancelled, we will get a null result
|
||||
// If null, return an empty list to avoid Rename failure dialog
|
||||
if (referencesResult !== null) {
|
||||
|
@ -735,9 +744,9 @@ export class DefaultClient implements Client {
|
|||
});
|
||||
};
|
||||
|
||||
if (referencesRequestPending) {
|
||||
if (referencesRequestPending || this.client.references.symbolSearchInProgress) {
|
||||
let cancelling: boolean = referencesPendingCancellations.length > 0;
|
||||
referencesPendingCancellations.push({ reject, callback });
|
||||
referencesPendingCancellations.push({ reject: () => { --renameRequestsPending; reject(); }, callback });
|
||||
if (!cancelling) {
|
||||
this.client.languageClient.sendNotification(CancelReferencesNotification);
|
||||
this.client.references.closeRenameUI();
|
||||
|
@ -2148,11 +2157,13 @@ export class DefaultClient implements Client {
|
|||
public cancelReferences(): void {
|
||||
referencesParams = null;
|
||||
renamePending = false;
|
||||
let cancelling: boolean = referencesPendingCancellations.length > 0;
|
||||
if (!cancelling) {
|
||||
if (referencesRequestPending || this.references.symbolSearchInProgress) {
|
||||
let cancelling: boolean = referencesPendingCancellations.length > 0;
|
||||
referencesPendingCancellations.push({ reject: () => {}, callback: () => {} });
|
||||
this.languageClient.sendNotification(CancelReferencesNotification);
|
||||
this.references.closeRenameUI();
|
||||
if (!cancelling) {
|
||||
this.languageClient.sendNotification(CancelReferencesNotification);
|
||||
this.references.closeRenameUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,6 +126,7 @@ export class ReferencesManager {
|
|||
private renameView: RenameView;
|
||||
private viewsInitialized: boolean = false;
|
||||
|
||||
public symbolSearchInProgress: boolean = false;
|
||||
private referencesCurrentProgress: ReportReferencesProgressNotification;
|
||||
private referencesPrevProgressIncrement: number;
|
||||
private referencesPrevProgressMessage: string;
|
||||
|
@ -343,7 +344,20 @@ export class ReferencesManager {
|
|||
this.referencesChannel.show(true);
|
||||
}
|
||||
|
||||
if (this.client.ReferencesCommandMode === ReferencesCommandMode.Rename) {
|
||||
let currentReferenceCommandMode: ReferencesCommandMode = this.client.ReferencesCommandMode;
|
||||
if (referencesResult.isFinished) {
|
||||
this.symbolSearchInProgress = false;
|
||||
clearInterval(this.referencesDelayProgress);
|
||||
if (this.currentUpdateProgressTimer) {
|
||||
clearInterval(this.currentUpdateProgressTimer);
|
||||
this.currentUpdateProgressResolve();
|
||||
this.currentUpdateProgressResolve = null;
|
||||
this.currentUpdateProgressTimer = null;
|
||||
}
|
||||
this.client.setReferencesCommandMode(ReferencesCommandMode.None);
|
||||
}
|
||||
|
||||
if (currentReferenceCommandMode === ReferencesCommandMode.Rename) {
|
||||
if (!this.referencesCanceled) {
|
||||
// If there are only Confirmed results, complete the rename immediately.
|
||||
let foundUnconfirmed: ReferenceInfo = referencesResult.referenceInfos.find(e => e.type !== ReferenceType.Confirmed);
|
||||
|
@ -353,40 +367,30 @@ export class ReferencesManager {
|
|||
this.renameView.show(true);
|
||||
this.renameView.setData(referencesResult, this.resultsCallback);
|
||||
}
|
||||
} else {
|
||||
// Do nothing when rename is canceled while searching for references was in progress.
|
||||
this.resultsCallback(null);
|
||||
}
|
||||
} else {
|
||||
// Put results in data model
|
||||
this.findAllRefsView.setData(referencesResult, this.referencesCanceled);
|
||||
|
||||
// Display data based on command mode: peek references OR find all references
|
||||
if (this.client.ReferencesCommandMode === ReferencesCommandMode.Peek) {
|
||||
if (currentReferenceCommandMode === ReferencesCommandMode.Peek) {
|
||||
let showConfirmedReferences: boolean = this.referencesCanceled;
|
||||
let peekReferencesResults: string = this.findAllRefsView.getResultsAsText(showConfirmedReferences);
|
||||
if (peekReferencesResults) {
|
||||
this.referencesChannel.appendLine(peekReferencesResults);
|
||||
this.referencesChannel.show(true);
|
||||
}
|
||||
} else if (this.client.ReferencesCommandMode === ReferencesCommandMode.Find) {
|
||||
} else if (currentReferenceCommandMode === ReferencesCommandMode.Find) {
|
||||
this.findAllRefsView.show(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (referencesResult.isFinished) {
|
||||
clearInterval(this.referencesDelayProgress);
|
||||
if (this.currentUpdateProgressTimer) {
|
||||
clearInterval(this.currentUpdateProgressTimer);
|
||||
this.currentUpdateProgressResolve();
|
||||
this.currentUpdateProgressResolve = null;
|
||||
this.currentUpdateProgressTimer = null;
|
||||
}
|
||||
if (this.client.ReferencesCommandMode !== ReferencesCommandMode.Rename) {
|
||||
this.resultsCallback(referencesResult);
|
||||
}
|
||||
this.client.setReferencesCommandMode(ReferencesCommandMode.None);
|
||||
this.resultsCallback(referencesResult);
|
||||
}
|
||||
}
|
||||
|
||||
public setResultsCallback(callback: (results: ReferencesResult) => void): void {
|
||||
this.symbolSearchInProgress = true;
|
||||
this.resultsCallback = callback;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче