@@ -119,24 +119,24 @@ export class HistoryTreeDataProvider extends DisposableObject {
119119 arguments : [ element ] ,
120120 } ;
121121
122- // Mark this query history item according to whether it has a
123- // SARIF file so that we can make context menu items conditionally
124- // available.
125- const hasResults = await element . completedQuery ?. query . hasInterpretedResults ( ) ;
126- treeItem . contextValue = hasResults
127- ? 'interpretedResultsItem'
128- : 'rawResultsItem' ;
129-
122+ // Populate the icon and the context value. We use the context value to
123+ // control which commands are visible in the context menu.
124+ let hasResults ;
130125 switch ( element . status ) {
131126 case QueryStatus . InProgress :
132- // TODO this is not a good icon.
133127 treeItem . iconPath = new ThemeIcon ( 'sync~spin' ) ;
128+ treeItem . contextValue = 'inProgressResultsItem' ;
134129 break ;
135130 case QueryStatus . Completed :
131+ hasResults = await element . completedQuery ?. query . hasInterpretedResults ( ) ;
136132 treeItem . iconPath = this . localSuccessIconPath ;
133+ treeItem . contextValue = hasResults
134+ ? 'interpretedResultsItem'
135+ : 'rawResultsItem' ;
137136 break ;
138137 case QueryStatus . Failed :
139138 treeItem . iconPath = this . failedIconPath ;
139+ treeItem . contextValue = 'cancelledResultsItem' ;
140140 break ;
141141 default :
142142 assertNever ( element . status ) ;
@@ -332,6 +332,12 @@ export class QueryHistoryManager extends DisposableObject {
332332 this . handleShowQueryLog . bind ( this )
333333 )
334334 ) ;
335+ this . push (
336+ commandRunner (
337+ 'codeQLQueryHistory.cancel' ,
338+ this . handleCancel . bind ( this )
339+ )
340+ ) ;
335341 this . push (
336342 commandRunner (
337343 'codeQLQueryHistory.showQueryText' ,
@@ -439,7 +445,7 @@ export class QueryHistoryManager extends DisposableObject {
439445 const { finalSingleItem, finalMultiSelect } = this . determineSelection ( singleItem , multiSelect ) ;
440446
441447 ( finalMultiSelect || [ finalSingleItem ] ) . forEach ( ( item ) => {
442- // TODO: Removing in progress queries is not supported yet
448+ // Removing in progress queries is not supported yet
443449 if ( item . status !== QueryStatus . InProgress ) {
444450 this . treeDataProvider . remove ( item ) ;
445451 item . completedQuery ?. dispose ( ) ;
@@ -568,6 +574,19 @@ export class QueryHistoryManager extends DisposableObject {
568574 }
569575 }
570576
577+ async handleCancel (
578+ singleItem : FullQueryInfo ,
579+ multiSelect : FullQueryInfo [ ]
580+ ) {
581+ const { finalSingleItem, finalMultiSelect } = this . determineSelection ( singleItem , multiSelect ) ;
582+
583+ ( finalMultiSelect || [ finalSingleItem ] ) . forEach ( ( item ) => {
584+ if ( item . status === QueryStatus . InProgress ) {
585+ item . cancel ( ) ;
586+ }
587+ } ) ;
588+ }
589+
571590 async handleShowQueryText (
572591 singleItem : FullQueryInfo ,
573592 multiSelect : FullQueryInfo [ ]
0 commit comments