@@ -286,6 +286,7 @@ let failureMessageShown: boolean = false;
286286
287287let referencesRequestPending : boolean = false ;
288288let renamePending : boolean = false ;
289+ let renameRequestsPending : number = 0 ;
289290let referencesParams : RenameParams | FindAllReferencesParams ;
290291
291292interface ReferencesCancellationState {
@@ -659,7 +660,7 @@ export class DefaultClient implements Client {
659660 } ) ;
660661 } ;
661662
662- if ( referencesRequestPending ) {
663+ if ( referencesRequestPending || ( this . client . references . symbolSearchInProgress && ! this . client . references . referencesViewFindPending ) ) {
663664 let cancelling : boolean = referencesPendingCancellations . length > 0 ;
664665 referencesPendingCancellations . push ( { reject, callback } ) ;
665666 if ( ! cancelling ) {
@@ -688,6 +689,7 @@ export class DefaultClient implements Client {
688689 // VS Code will attempt to issue new rename requests while another is still active.
689690 // When we receive another rename request, cancel the one that is in progress.
690691 renamePending = true ;
692+ ++ renameRequestsPending ;
691693 return new Promise < vscode . WorkspaceEdit > ( ( resolve , reject ) => {
692694 let callback : ( ) => void = ( ) => {
693695 let params : RenameParams = {
@@ -700,13 +702,17 @@ export class DefaultClient implements Client {
700702 // The current request is represented by referencesParams. If a request detects
701703 // referencesParams does not match the object used when creating the request, abort it.
702704 if ( params !== referencesParams ) {
705+ if ( -- renameRequestsPending === 0 ) {
706+ renamePending = false ;
707+ }
703708 reject ( ) ;
704709 return ;
705710 }
706711 referencesRequestPending = true ;
707712 this . client . languageClient . sendNotification ( RenameNotification , params ) ;
708713 this . client . references . setResultsCallback ( ( referencesResult ) => {
709714 referencesRequestPending = false ;
715+ -- renameRequestsPending ;
710716 let workspaceEdit : vscode . WorkspaceEdit = new vscode . WorkspaceEdit ( ) ;
711717 let cancelling : boolean = referencesPendingCancellations . length > 0 ;
712718 if ( cancelling ) {
@@ -719,6 +725,9 @@ export class DefaultClient implements Client {
719725 referencesPendingCancellations . pop ( ) ;
720726 pendingCancel . callback ( ) ;
721727 } else {
728+ if ( renameRequestsPending === 0 ) {
729+ renamePending = false ;
730+ }
722731 // If rename UI Was cancelled, we will get a null result
723732 // If null, return an empty list to avoid Rename failure dialog
724733 if ( referencesResult !== null ) {
@@ -735,9 +744,9 @@ export class DefaultClient implements Client {
735744 } ) ;
736745 } ;
737746
738- if ( referencesRequestPending ) {
747+ if ( referencesRequestPending || this . client . references . symbolSearchInProgress ) {
739748 let cancelling : boolean = referencesPendingCancellations . length > 0 ;
740- referencesPendingCancellations . push ( { reject, callback } ) ;
749+ referencesPendingCancellations . push ( { reject : ( ) => { -- renameRequestsPending ; reject ( ) ; } , callback } ) ;
741750 if ( ! cancelling ) {
742751 this . client . languageClient . sendNotification ( CancelReferencesNotification ) ;
743752 this . client . references . closeRenameUI ( ) ;
@@ -2148,11 +2157,13 @@ export class DefaultClient implements Client {
21482157 public cancelReferences ( ) : void {
21492158 referencesParams = null ;
21502159 renamePending = false ;
2151- let cancelling : boolean = referencesPendingCancellations . length > 0 ;
2152- if ( ! cancelling ) {
2160+ if ( referencesRequestPending || this . references . symbolSearchInProgress ) {
2161+ let cancelling : boolean = referencesPendingCancellations . length > 0 ;
21532162 referencesPendingCancellations . push ( { reject : ( ) => { } , callback : ( ) => { } } ) ;
2154- this . languageClient . sendNotification ( CancelReferencesNotification ) ;
2155- this . references . closeRenameUI ( ) ;
2163+ if ( ! cancelling ) {
2164+ this . languageClient . sendNotification ( CancelReferencesNotification ) ;
2165+ this . references . closeRenameUI ( ) ;
2166+ }
21562167 }
21572168 }
21582169
0 commit comments