@@ -444,20 +444,28 @@ async function activateWithInstalledDistribution(
444444 commands . registerCommand (
445445 'codeQL.runQueries' ,
446446 async ( _ : Uri | undefined , multi : Uri [ ] ) => {
447- const [ files , dirFound ] = await gatherQlFiles ( multi . map ( uri => uri . fsPath ) ) ;
448- // warn user and display selected files when a directory is selected because some ql
449- // files may be hidden from the user.
450- if ( dirFound ) {
451- const fileString = files . map ( file => path . basename ( file ) ) . join ( ', ' ) ;
452- const res = await helpers . showBinaryChoiceDialog (
453- `You are about to run ${ files . length } queries: ${ fileString } Do you want to continue?`
454- ) ;
455- if ( ! res ) {
456- return ;
447+ const maxQueryCount = 20 ;
448+ try {
449+ const [ files , dirFound ] = await gatherQlFiles ( multi . map ( uri => uri . fsPath ) ) ;
450+ if ( files . length > maxQueryCount ) {
451+ throw new Error ( `You tried to run ${ files . length } queries, but the maximum is ${ maxQueryCount } . Try selecting fewer queries.` ) ;
457452 }
453+ // warn user and display selected files when a directory is selected because some ql
454+ // files may be hidden from the user.
455+ if ( dirFound ) {
456+ const fileString = files . map ( file => path . basename ( file ) ) . join ( ', ' ) ;
457+ const res = await helpers . showBinaryChoiceDialog (
458+ `You are about to run ${ files . length } queries: ${ fileString } Do you want to continue?`
459+ ) ;
460+ if ( ! res ) {
461+ return ;
462+ }
463+ }
464+ const queryUris = files . map ( path => Uri . parse ( `file:${ path } ` , true ) ) ;
465+ await Promise . all ( queryUris . map ( uri => compileAndRunQuery ( false , uri ) ) ) ;
466+ } catch ( e ) {
467+ helpers . showAndLogErrorMessage ( e . message ) ;
458468 }
459- const queryUris = files . map ( path => Uri . parse ( `file:${ path } ` , true ) ) ;
460- await Promise . all ( queryUris . map ( uri => compileAndRunQuery ( false , uri ) ) ) ;
461469 }
462470 )
463471 ) ;
0 commit comments