@@ -19,6 +19,7 @@ import type { CodeQLCliServer } from "../codeql-cli/cli";
1919import type { DatabaseManager } from "../databases/local-databases" ;
2020import { jumpToLocation } from "../databases/local-databases/locations" ;
2121import type { BqrsInfo , BqrsResultSetSchema } from "../common/bqrs-cli-types" ;
22+ // eslint-disable-next-line import/no-deprecated
2223import resultsDiff from "./resultsDiff" ;
2324import type { CompletedLocalQueryInfo } from "../query-results" ;
2425import { assertNever , getErrorMessage } from "../common/helpers-pure" ;
@@ -403,13 +404,18 @@ export class CompareView extends AbstractWebview<
403404 toResultSetName ,
404405 ) ;
405406
406- // If the result set names are the same, we use `bqrs diff`. This is more
407- // efficient, but we can't use it in general as it does not support
408- // comparing different result sets.
409- if ( fromResultSetName === toResultSetName ) {
407+ // We use `bqrs diff` when the `--result-sets` option is supported, or when
408+ // the result set names are the same (in which case we don't need the
409+ // option).
410+ const supportsBqrsDiffResultSets =
411+ await this . cliServer . supportsFeature ( "bqrsDiffResultSets" ) ;
412+ if ( supportsBqrsDiffResultSets || fromResultSetName === toResultSetName ) {
410413 const { uniquePath1, uniquePath2, cleanup } =
411414 await this . cliServer . bqrsDiff ( fromPath , toPath , {
412415 retainResultSets : [ ] ,
416+ resultSets : supportsBqrsDiffResultSets
417+ ? [ [ fromResultSetName , toResultSetName ] ]
418+ : [ ] ,
413419 } ) ;
414420 try {
415421 const uniqueInfo1 = await this . cliServer . bqrsInfo ( uniquePath1 ) ;
@@ -443,10 +449,13 @@ export class CompareView extends AbstractWebview<
443449 await cleanup ( ) ;
444450 }
445451 } else {
452+ // Legacy code path: Perform the diff directly in the extension when we
453+ // can't use `bqrs diff`.
446454 const [ fromResultSet , toResultSet ] = await Promise . all ( [
447455 this . getResultSet ( fromInfo . schemas , fromResultSetName , fromPath ) ,
448456 this . getResultSet ( toInfo . schemas , toResultSetName , toPath ) ,
449457 ] ) ;
458+ // eslint-disable-next-line import/no-deprecated
450459 return resultsDiff ( fromResultSet , toResultSet ) ;
451460 }
452461 }
0 commit comments