@@ -72,6 +72,12 @@ async function promptToSaveQueryIfNeeded(query: SelectedQuery): Promise<void> {
7272 }
7373}
7474
75+ export enum QuickEvalType {
76+ None ,
77+ QuickEval ,
78+ QuickEvalCount ,
79+ }
80+
7581export class LocalQueries extends DisposableObject {
7682 public constructor (
7783 private readonly app : App ,
@@ -115,7 +121,13 @@ export class LocalQueries extends DisposableObject {
115121 private async runQuery ( uri : Uri | undefined ) : Promise < void > {
116122 await withProgress (
117123 async ( progress , token ) => {
118- await this . compileAndRunQuery ( false , uri , progress , token , undefined ) ;
124+ await this . compileAndRunQuery (
125+ QuickEvalType . None ,
126+ uri ,
127+ progress ,
128+ token ,
129+ undefined ,
130+ ) ;
119131 } ,
120132 {
121133 title : "Running query" ,
@@ -185,7 +197,7 @@ export class LocalQueries extends DisposableObject {
185197 await Promise . all (
186198 queryUris . map ( async ( uri ) =>
187199 this . compileAndRunQuery (
188- false ,
200+ QuickEvalType . None ,
189201 uri ,
190202 wrappedProgress ,
191203 token ,
@@ -204,7 +216,13 @@ export class LocalQueries extends DisposableObject {
204216 private async quickEval ( uri : Uri ) : Promise < void > {
205217 await withProgress (
206218 async ( progress , token ) => {
207- await this . compileAndRunQuery ( true , uri , progress , token , undefined ) ;
219+ await this . compileAndRunQuery (
220+ QuickEvalType . QuickEval ,
221+ uri ,
222+ progress ,
223+ token ,
224+ undefined ,
225+ ) ;
208226 } ,
209227 {
210228 title : "Running query" ,
@@ -217,7 +235,7 @@ export class LocalQueries extends DisposableObject {
217235 await withProgress (
218236 async ( progress , token ) =>
219237 await this . compileAndRunQuery (
220- true ,
238+ QuickEvalType . QuickEval ,
221239 uri ,
222240 progress ,
223241 token ,
@@ -331,7 +349,7 @@ export class LocalQueries extends DisposableObject {
331349 }
332350
333351 public async compileAndRunQuery (
334- quickEval : boolean ,
352+ quickEval : QuickEvalType ,
335353 queryUri : Uri | undefined ,
336354 progress : ProgressCallback ,
337355 token : CancellationToken ,
@@ -352,7 +370,7 @@ export class LocalQueries extends DisposableObject {
352370
353371 /** Used by tests */
354372 public async compileAndRunQueryInternal (
355- quickEval : boolean ,
373+ quickEval : QuickEvalType ,
356374 queryUri : Uri | undefined ,
357375 progress : ProgressCallback ,
358376 token : CancellationToken ,
@@ -364,15 +382,20 @@ export class LocalQueries extends DisposableObject {
364382 if ( queryUri !== undefined ) {
365383 // The query URI is provided by the command, most likely because the command was run from an
366384 // editor context menu. Use the provided URI, but make sure it's a valid query.
367- queryPath = validateQueryUri ( queryUri , quickEval ) ;
385+ queryPath = validateQueryUri ( queryUri , quickEval !== QuickEvalType . None ) ;
368386 } else {
369387 // Use the currently selected query.
370- queryPath = await this . getCurrentQuery ( quickEval ) ;
388+ queryPath = await this . getCurrentQuery ( quickEval !== QuickEvalType . None ) ;
371389 }
372390
373391 const selectedQuery : SelectedQuery = {
374392 queryPath,
375- quickEval : quickEval ? await getQuickEvalContext ( range ) : undefined ,
393+ quickEval : quickEval
394+ ? await getQuickEvalContext (
395+ range ,
396+ quickEval === QuickEvalType . QuickEvalCount ,
397+ )
398+ : undefined ,
376399 } ;
377400
378401 // If no databaseItem is specified, use the database currently selected in the Databases UI
@@ -392,6 +415,7 @@ export class LocalQueries extends DisposableObject {
392415 {
393416 queryPath : selectedQuery . queryPath ,
394417 quickEvalPosition : selectedQuery . quickEval ?. quickEvalPosition ,
418+ quickEvalCountOnly : selectedQuery . quickEval ?. quickEvalCount ,
395419 } ,
396420 true ,
397421 additionalPacks ,
@@ -481,7 +505,7 @@ export class LocalQueries extends DisposableObject {
481505 for ( const item of quickpick ) {
482506 try {
483507 await this . compileAndRunQuery (
484- false ,
508+ QuickEvalType . None ,
485509 uri ,
486510 progress ,
487511 token ,
0 commit comments