11import { join , dirname } from "path" ;
22import {
3- commands ,
43 Disposable ,
54 env ,
65 EventEmitter ,
@@ -26,12 +25,7 @@ import { extLogger } from "../common";
2625import { URLSearchParams } from "url" ;
2726import { DisposableObject } from "../pure/disposable-object" ;
2827import { ONE_HOUR_IN_MS , TWO_HOURS_IN_MS } from "../pure/time" ;
29- import {
30- asError ,
31- assertNever ,
32- getErrorMessage ,
33- getErrorStack ,
34- } from "../pure/helpers-pure" ;
28+ import { asError , assertNever , getErrorMessage } from "../pure/helpers-pure" ;
3529import { CompletedLocalQueryInfo , LocalQueryInfo } from "../query-results" ;
3630import {
3731 getActionsWorkflowRunUrl ,
@@ -66,6 +60,8 @@ import { HistoryTreeDataProvider } from "./history-tree-data-provider";
6660import { redactableError } from "../pure/errors" ;
6761import { QueryHistoryDirs } from "./query-history-dirs" ;
6862import { QueryHistoryCommands } from "../common/commands" ;
63+ import { App } from "../common/app" ;
64+ import { tryOpenExternalFile } from "../vscode-utils/external-files" ;
6965
7066/**
7167 * query-history-manager.ts
@@ -135,6 +131,7 @@ export class QueryHistoryManager extends DisposableObject {
135131 readonly onDidCompleteQuery = this . _onDidCompleteQuery . event ;
136132
137133 constructor (
134+ private readonly app : App ,
138135 private readonly qs : QueryRunner ,
139136 private readonly dbm : DatabaseManager ,
140137 private readonly localQueriesResultsView : ResultsView ,
@@ -683,7 +680,10 @@ export class QueryHistoryManager extends DisposableObject {
683680 }
684681
685682 if ( singleItem . completedQuery . logFileLocation ) {
686- await this . tryOpenExternalFile ( singleItem . completedQuery . logFileLocation ) ;
683+ await tryOpenExternalFile (
684+ this . app . commands ,
685+ singleItem . completedQuery . logFileLocation ,
686+ ) ;
687687 } else {
688688 void showAndLogWarningMessage ( "No log file available" ) ;
689689 }
@@ -751,7 +751,7 @@ export class QueryHistoryManager extends DisposableObject {
751751 }
752752 }
753753 try {
754- await commands . executeCommand (
754+ await this . app . commands . execute (
755755 "revealFileInOS" ,
756756 Uri . file ( externalFilePath ) ,
757757 ) ;
@@ -800,7 +800,10 @@ export class QueryHistoryManager extends DisposableObject {
800800 }
801801
802802 if ( finalSingleItem . evalLogLocation ) {
803- await this . tryOpenExternalFile ( finalSingleItem . evalLogLocation ) ;
803+ await tryOpenExternalFile (
804+ this . app . commands ,
805+ finalSingleItem . evalLogLocation ,
806+ ) ;
804807 } else {
805808 this . warnNoEvalLogs ( ) ;
806809 }
@@ -825,7 +828,10 @@ export class QueryHistoryManager extends DisposableObject {
825828 }
826829
827830 if ( finalSingleItem . evalLogSummaryLocation ) {
828- await this . tryOpenExternalFile ( finalSingleItem . evalLogSummaryLocation ) ;
831+ await tryOpenExternalFile (
832+ this . app . commands ,
833+ finalSingleItem . evalLogSummaryLocation ,
834+ ) ;
829835 return ;
830836 }
831837
@@ -968,7 +974,10 @@ export class QueryHistoryManager extends DisposableObject {
968974 const query = finalSingleItem . completedQuery . query ;
969975 const hasInterpretedResults = query . canHaveInterpretedResults ( ) ;
970976 if ( hasInterpretedResults ) {
971- await this . tryOpenExternalFile ( query . resultsPaths . interpretedResultsPath ) ;
977+ await tryOpenExternalFile (
978+ this . app . commands ,
979+ query . resultsPaths . interpretedResultsPath ,
980+ ) ;
972981 } else {
973982 const label = this . labelProvider . getLabel ( finalSingleItem ) ;
974983 void showAndLogInformationMessage (
@@ -997,11 +1006,11 @@ export class QueryHistoryManager extends DisposableObject {
9971006 }
9981007 const query = finalSingleItem . completedQuery . query ;
9991008 if ( await query . hasCsv ( ) ) {
1000- void this . tryOpenExternalFile ( query . csvPath ) ;
1009+ void tryOpenExternalFile ( this . app . commands , query . csvPath ) ;
10011010 return ;
10021011 }
10031012 if ( await query . exportCsvResults ( this . qs . cliServer , query . csvPath ) ) {
1004- void this . tryOpenExternalFile ( query . csvPath ) ;
1013+ void tryOpenExternalFile ( this . app . commands , query . csvPath ) ;
10051014 }
10061015 }
10071016
@@ -1024,7 +1033,8 @@ export class QueryHistoryManager extends DisposableObject {
10241033 return ;
10251034 }
10261035
1027- await this . tryOpenExternalFile (
1036+ await tryOpenExternalFile (
1037+ this . app . commands ,
10281038 await finalSingleItem . completedQuery . query . ensureCsvAlerts (
10291039 this . qs . cliServer ,
10301040 this . dbm ,
@@ -1051,7 +1061,8 @@ export class QueryHistoryManager extends DisposableObject {
10511061 return ;
10521062 }
10531063
1054- await this . tryOpenExternalFile (
1064+ await tryOpenExternalFile (
1065+ this . app . commands ,
10551066 await finalSingleItem . completedQuery . query . ensureDilPath (
10561067 this . qs . cliServer ,
10571068 ) ,
@@ -1077,7 +1088,7 @@ export class QueryHistoryManager extends DisposableObject {
10771088
10781089 const actionsWorkflowRunUrl = getActionsWorkflowRunUrl ( finalSingleItem ) ;
10791090
1080- await commands . executeCommand (
1091+ await this . app . commands . execute (
10811092 "vscode.open" ,
10821093 Uri . parse ( actionsWorkflowRunUrl ) ,
10831094 ) ;
@@ -1101,7 +1112,7 @@ export class QueryHistoryManager extends DisposableObject {
11011112 return ;
11021113 }
11031114
1104- await commands . executeCommand (
1115+ await this . app . commands . execute (
11051116 "codeQL.copyVariantAnalysisRepoList" ,
11061117 finalSingleItem . variantAnalysis . id ,
11071118 ) ;
@@ -1171,47 +1182,6 @@ export class QueryHistoryManager extends DisposableObject {
11711182 }
11721183 }
11731184
1174- private async tryOpenExternalFile ( fileLocation : string ) {
1175- const uri = Uri . file ( fileLocation ) ;
1176- try {
1177- await window . showTextDocument ( uri , { preview : false } ) ;
1178- } catch ( e ) {
1179- const msg = getErrorMessage ( e ) ;
1180- if (
1181- msg . includes (
1182- "Files above 50MB cannot be synchronized with extensions" ,
1183- ) ||
1184- msg . includes ( "too large to open" )
1185- ) {
1186- const res = await showBinaryChoiceDialog (
1187- `VS Code does not allow extensions to open files >50MB. This file
1188- exceeds that limit. Do you want to open it outside of VS Code?
1189-
1190- You can also try manually opening it inside VS Code by selecting
1191- the file in the file explorer and dragging it into the workspace.` ,
1192- ) ;
1193- if ( res ) {
1194- try {
1195- await commands . executeCommand ( "revealFileInOS" , uri ) ;
1196- } catch ( e ) {
1197- void showAndLogExceptionWithTelemetry (
1198- redactableError (
1199- asError ( e ) ,
1200- ) `Failed to reveal file in OS: ${ getErrorMessage ( e ) } ` ,
1201- ) ;
1202- }
1203- }
1204- } else {
1205- void showAndLogExceptionWithTelemetry (
1206- redactableError ( asError ( e ) ) `Could not open file ${ fileLocation } ` ,
1207- {
1208- fullMessage : `${ getErrorMessage ( e ) } \n${ getErrorStack ( e ) } ` ,
1209- } ,
1210- ) ;
1211- }
1212- }
1213- }
1214-
12151185 private async findOtherQueryToCompare (
12161186 singleItem : QueryHistoryInfo ,
12171187 multiSelect : QueryHistoryInfo [ ] ,
0 commit comments