@@ -59,6 +59,7 @@ import { QueryHistoryDirs } from "./query-history-dirs";
5959import { QueryHistoryCommands } from "../common/commands" ;
6060import { App } from "../common/app" ;
6161import { tryOpenExternalFile } from "../vscode-utils/external-files" ;
62+ import { createSingleSelectionCommand } from "../common/selection-commands" ;
6263
6364/**
6465 * query-history-manager.ts
@@ -235,8 +236,10 @@ export class QueryHistoryManager extends DisposableObject {
235236 "codeQLQueryHistory.sortByDate" : this . handleSortByDate . bind ( this ) ,
236237 "codeQLQueryHistory.sortByCount" : this . handleSortByCount . bind ( this ) ,
237238
238- "codeQLQueryHistory.openQueryContextMenu" :
239+ "codeQLQueryHistory.openQueryContextMenu" : createSingleSelectionCommand (
239240 this . handleOpenQuery . bind ( this ) ,
241+ "query" ,
242+ ) ,
240243 "codeQLQueryHistory.removeHistoryItemContextMenu" :
241244 this . handleRemoveHistoryItem . bind ( this ) ,
242245 "codeQLQueryHistory.removeHistoryItemContextInline" :
@@ -395,35 +398,26 @@ export class QueryHistoryManager extends DisposableObject {
395398 ) ;
396399 }
397400
398- async handleOpenQuery (
399- singleItem : QueryHistoryInfo ,
400- multiSelect : QueryHistoryInfo [ ] | undefined ,
401- ) : Promise < void > {
402- if ( ! this . assertSingleQuery ( multiSelect ) ) {
403- return ;
404- }
405-
406- if ( singleItem . t === "variant-analysis" ) {
407- await this . variantAnalysisManager . openQueryFile (
408- singleItem . variantAnalysis . id ,
409- ) ;
401+ async handleOpenQuery ( item : QueryHistoryInfo ) : Promise < void > {
402+ if ( item . t === "variant-analysis" ) {
403+ await this . variantAnalysisManager . openQueryFile ( item . variantAnalysis . id ) ;
410404 return ;
411405 }
412406
413407 let queryPath : string ;
414- switch ( singleItem . t ) {
408+ switch ( item . t ) {
415409 case "local" :
416- queryPath = singleItem . initialInfo . queryPath ;
410+ queryPath = item . initialInfo . queryPath ;
417411 break ;
418412 default :
419- assertNever ( singleItem ) ;
413+ assertNever ( item ) ;
420414 }
421415 const textDocument = await workspace . openTextDocument ( Uri . file ( queryPath ) ) ;
422416 const editor = await window . showTextDocument ( textDocument , ViewColumn . One ) ;
423417
424- if ( singleItem . t === "local" ) {
425- const queryText = singleItem . initialInfo . queryText ;
426- if ( queryText !== undefined && singleItem . initialInfo . isQuickQuery ) {
418+ if ( item . t === "local" ) {
419+ const queryText = item . initialInfo . queryText ;
420+ if ( queryText !== undefined && item . initialInfo . isQuickQuery ) {
427421 await editor . edit ( ( edit ) =>
428422 edit . replace (
429423 textDocument . validateRange (
@@ -629,7 +623,7 @@ export class QueryHistoryManager extends DisposableObject {
629623 singleItem === prevItemClick . item
630624 ) {
631625 // show original query file on double click
632- await this . handleOpenQuery ( singleItem , [ singleItem ] ) ;
626+ await this . handleOpenQuery ( singleItem ) ;
633627 } else if (
634628 singleItem . t === "variant-analysis" ||
635629 singleItem . status === QueryStatus . Completed
0 commit comments