@@ -5,7 +5,6 @@ import { CancellationToken, window as Window, workspace, Uri } from "vscode";
55import { LSPErrorCodes , ResponseError } from "vscode-languageclient" ;
66import { CodeQLCliServer } from "../codeql-cli/cli" ;
77import { DatabaseUI } from "../databases/local-databases-ui" ;
8- import { showBinaryChoiceDialog } from "../common/vscode/dialog" ;
98import { getInitialQueryContents } from "./query-contents" ;
109import { getPrimaryDbscheme , getQlPackForDbscheme } from "../databases/qlpack" ;
1110import {
@@ -15,6 +14,7 @@ import {
1514import { getErrorMessage } from "../common/helpers-pure" ;
1615import { FALLBACK_QLPACK_FILENAME , getQlPackPath } from "../common/ql" ;
1716import { App } from "../common/app" ;
17+ import { ExtensionApp } from "../common/vscode/vscode-app" ;
1818
1919const QUICK_QUERIES_DIR_NAME = "quick-queries" ;
2020const QUICK_QUERY_QUERY_NAME = "quick-query.ql" ;
@@ -52,7 +52,7 @@ function findExistingQuickQueryEditor() {
5252 * Show a buffer the user can enter a simple query into.
5353 */
5454export async function displayQuickQuery (
55- app : App ,
55+ app : ExtensionApp ,
5656 cliServer : CodeQLCliServer ,
5757 databaseUI : DatabaseUI ,
5858 progress : ProgressCallback ,
@@ -80,12 +80,24 @@ export async function displayQuickQuery(
8080 // being undefined) just let the user know that they're in for a
8181 // restart.
8282 if ( workspace . workspaceFile === undefined ) {
83- const makeMultiRoot = await showBinaryChoiceDialog (
84- "Quick query requires multiple folders in the workspace. Reload workspace as multi-folder workspace?" ,
83+ const createQueryOption = 'Run "Create query"' ;
84+ const quickQueryOption = 'Run "Quick query" anyway' ;
85+ const quickQueryPrompt = await Window . showWarningMessage (
86+ '"Quick query" requires reloading your workspace as a multi-root workspace, which may cause query history and databases to be lost.' ,
87+ {
88+ modal : true ,
89+ detail :
90+ 'The "Create query" command does not require reloading the workspace.' ,
91+ } ,
92+ createQueryOption ,
93+ quickQueryOption ,
8594 ) ;
86- if ( makeMultiRoot ) {
95+ if ( quickQueryPrompt === quickQueryOption ) {
8796 updateQuickQueryDir ( queriesDir , workspaceFolders . length , 0 ) ;
8897 }
98+ if ( quickQueryPrompt === createQueryOption ) {
99+ await app . queryServerCommands . execute ( "codeQL.createQuery" ) ;
100+ }
89101 return ;
90102 }
91103
0 commit comments