@@ -505,7 +505,7 @@ export class QueryHistoryManager extends DisposableObject {
505505 this . push (
506506 queryHistoryConfigListener . onDidChangeConfiguration ( ( ) => {
507507 this . treeDataProvider . refresh ( ) ;
508- this . registerQueryHistoryScrubber ( queryHistoryConfigListener , ctx ) ;
508+ this . registerQueryHistoryScrubber ( queryHistoryConfigListener , this , ctx ) ;
509509 } )
510510 ) ;
511511
@@ -524,7 +524,7 @@ export class QueryHistoryManager extends DisposableObject {
524524 } ,
525525 } ) ) ;
526526
527- this . registerQueryHistoryScrubber ( queryHistoryConfigListener , ctx ) ;
527+ this . registerQueryHistoryScrubber ( queryHistoryConfigListener , this , ctx ) ;
528528 this . registerToRemoteQueriesEvents ( ) ;
529529 }
530530
@@ -535,7 +535,7 @@ export class QueryHistoryManager extends DisposableObject {
535535 /**
536536 * Register and create the history scrubber.
537537 */
538- private registerQueryHistoryScrubber ( queryHistoryConfigListener : QueryHistoryConfig , ctx : ExtensionContext ) {
538+ private registerQueryHistoryScrubber ( queryHistoryConfigListener : QueryHistoryConfig , qhm : QueryHistoryManager , ctx : ExtensionContext ) {
539539 this . queryHistoryScrubber ?. dispose ( ) ;
540540 // Every hour check if we need to re-run the query history scrubber.
541541 this . queryHistoryScrubber = this . push (
@@ -544,6 +544,7 @@ export class QueryHistoryManager extends DisposableObject {
544544 TWO_HOURS_IN_MS ,
545545 queryHistoryConfigListener . ttlInMillis ,
546546 this . queryStorageDir ,
547+ qhm ,
547548 ctx
548549 )
549550 ) ;
@@ -639,6 +640,15 @@ export class QueryHistoryManager extends DisposableObject {
639640 return this . treeDataProvider . getCurrent ( ) ;
640641 }
641642
643+ async removeDeletedQueries ( ) {
644+ await Promise . all ( this . treeDataProvider . allHistory . map ( async ( item ) => {
645+ if ( item . t == 'local' && item . completedQuery && ! ( await fs . pathExists ( item . completedQuery ?. query . querySaveDir ) ) ) {
646+ this . treeDataProvider . remove ( item ) ;
647+ item . completedQuery ?. dispose ( ) ;
648+ }
649+ } ) ) ;
650+ }
651+
642652 async handleRemoveHistoryItem (
643653 singleItem : QueryHistoryInfo ,
644654 multiSelect : QueryHistoryInfo [ ] = [ ]
0 commit comments