1
1
import * as path from 'path' ;
2
+ import * as fs from 'fs-extra' ;
2
3
import * as vscode from 'vscode' ;
3
4
import { window as Window , env } from 'vscode' ;
4
5
import { CompletedQuery } from './query-results' ;
@@ -306,20 +307,20 @@ export class QueryHistoryManager extends DisposableObject {
306
307
) ;
307
308
this . push (
308
309
commandRunner (
309
- 'codeQLQueryHistory.exportCsvResults ' ,
310
- this . handleExportCsvResults . bind ( this )
310
+ 'codeQLQueryHistory.viewCsvResults ' ,
311
+ this . handleViewCsvResults . bind ( this )
311
312
)
312
313
) ;
313
314
this . push (
314
315
commandRunner (
315
- 'codeQLQueryHistory.viewCsvResults ' ,
316
- this . handleViewCsvResults . bind ( this )
316
+ 'codeQLQueryHistory.viewCsvAlerts ' ,
317
+ this . handleViewCsvAlerts . bind ( this )
317
318
)
318
319
) ;
319
320
this . push (
320
321
commandRunner (
321
- 'codeQLQueryHistory.viewSarifResults ' ,
322
- this . handleViewSarifResults . bind ( this )
322
+ 'codeQLQueryHistory.viewSarifAlerts ' ,
323
+ this . handleViewSarifAlerts . bind ( this )
323
324
)
324
325
) ;
325
326
this . push (
@@ -556,7 +557,7 @@ export class QueryHistoryManager extends DisposableObject {
556
557
await vscode . window . showTextDocument ( doc , { preview : false } ) ;
557
558
}
558
559
559
- async handleViewSarifResults (
560
+ async handleViewSarifAlerts (
560
561
singleItem : CompletedQuery ,
561
562
multiSelect : CompletedQuery [ ]
562
563
) {
@@ -577,33 +578,25 @@ export class QueryHistoryManager extends DisposableObject {
577
578
}
578
579
}
579
580
580
- async handleExportCsvResults (
581
+ async handleViewCsvResults (
581
582
singleItem : CompletedQuery ,
582
583
multiSelect : CompletedQuery [ ]
583
584
) {
584
585
if ( ! this . assertSingleQuery ( multiSelect ) ) {
585
586
return ;
586
587
}
587
-
588
- const saveLocation = await vscode . window . showSaveDialog ( {
589
- title : 'CSV Results' ,
590
- saveLabel : 'Export' ,
591
- filters : {
592
- 'Comma-separated values' : [ 'csv' ] ,
593
- }
594
- } ) ;
595
- if ( ! saveLocation ) {
596
- void showAndLogErrorMessage ( 'No save location selected for CSV export!' ) ;
588
+ if ( await singleItem . query . hasCsv ( ) ) {
589
+ void this . tryOpenExternalFile ( singleItem . query . csvPath ) ;
597
590
return ;
598
591
}
599
- await singleItem . query . exportCsvResults ( this . qs , saveLocation . fsPath , ( ) => {
592
+ await singleItem . query . exportCsvResults ( this . qs , singleItem . query . csvPath , ( ) => {
600
593
void this . tryOpenExternalFile (
601
- saveLocation . fsPath
594
+ singleItem . query . csvPath
602
595
) ;
603
596
} ) ;
604
597
}
605
598
606
- async handleViewCsvResults (
599
+ async handleViewCsvAlerts (
607
600
singleItem : CompletedQuery ,
608
601
multiSelect : CompletedQuery [ ]
609
602
) {
0 commit comments