@@ -56,7 +56,7 @@ export class CodebaseIndexer {
5656 // and only need to `await` it for tests.
5757 public initPromise : Promise < void > ;
5858 private config ! : ContinueConfig ;
59- private indexingCancellationController : AbortController | undefined ;
59+ private indexingCancellationController : AbortController ;
6060 private codebaseIndexingState : IndexingProgressUpdate ;
6161 private readonly pauseToken : PauseToken ;
6262
@@ -97,6 +97,9 @@ export class CodebaseIndexer {
9797 this . pauseToken = new PauseToken ( initialPaused ) ;
9898
9999 this . initPromise = this . init ( configHandler ) ;
100+
101+ this . indexingCancellationController = new AbortController ( ) ;
102+ this . indexingCancellationController . abort ( ) ; // initialize and abort so that a new one can be created
100103 }
101104
102105 // Initialization - load config and attach config listener
@@ -693,7 +696,7 @@ export class CodebaseIndexer {
693696 }
694697
695698 public async refreshCodebaseIndex ( paths : string [ ] ) {
696- if ( this . indexingCancellationController ) {
699+ if ( ! this . indexingCancellationController . signal . aborted ) {
697700 this . indexingCancellationController . abort ( ) ;
698701 }
699702 const localController = new AbortController ( ) ;
@@ -735,16 +738,13 @@ export class CodebaseIndexer {
735738 } ) ;
736739 }
737740 if ( this . indexingCancellationController === localController ) {
738- this . indexingCancellationController = undefined ;
741+ this . indexingCancellationController . abort ( ) ;
739742 }
740743 }
741744
742745 public async refreshCodebaseIndexFiles ( files : string [ ] ) {
743746 // Can be cancelled by codebase index but not vice versa
744- if (
745- this . indexingCancellationController &&
746- ! this . indexingCancellationController . signal . aborted
747- ) {
747+ if ( ! this . indexingCancellationController . signal . aborted ) {
748748 return ;
749749 }
750750 const localController = new AbortController ( ) ;
@@ -770,7 +770,7 @@ export class CodebaseIndexer {
770770 } ) ;
771771 }
772772 if ( this . indexingCancellationController === localController ) {
773- this . indexingCancellationController = undefined ;
773+ this . indexingCancellationController . abort ( ) ;
774774 }
775775 }
776776
0 commit comments