55
66'use strict' ;
77import * as vscode from 'vscode' ;
8+ import { commands } from './executeCommands' ;
89import { PR_SETTINGS_NAMESPACE , QUERIES , USE_REVIEW_MODE } from './settingKeys' ;
910
1011export function getReviewMode ( ) : { merged : boolean , closed : boolean } {
@@ -53,7 +54,12 @@ export function editQuery(namespace: string, queryName: string) {
5354 const inputBox = vscode . window . createQuickPick ( ) ;
5455 inputBox . title = vscode . l10n . t ( 'Edit Query "{0}"' , queryName ?? '' ) ;
5556 inputBox . value = queryValue ?? '' ;
56- inputBox . items = [ { iconPath : new vscode . ThemeIcon ( 'pencil' ) , label : vscode . l10n . t ( 'Save edits' ) , alwaysShow : true } , { iconPath : new vscode . ThemeIcon ( 'add' ) , label : vscode . l10n . t ( 'Add new query' ) , alwaysShow : true } , { iconPath : new vscode . ThemeIcon ( 'settings' ) , label : vscode . l10n . t ( 'Edit in settings.json' ) , alwaysShow : true } ] ;
57+ inputBox . items = [
58+ { iconPath : new vscode . ThemeIcon ( 'pencil' ) , label : vscode . l10n . t ( 'Save edits' ) , alwaysShow : true } ,
59+ { iconPath : new vscode . ThemeIcon ( 'add' ) , label : vscode . l10n . t ( 'Add new query' ) , alwaysShow : true } ,
60+ { iconPath : new vscode . ThemeIcon ( 'settings' ) , label : vscode . l10n . t ( 'Edit in settings.json' ) , alwaysShow : true } ,
61+ { iconPath : new vscode . ThemeIcon ( 'copilot' ) , label : vscode . l10n . t ( 'Edit with Copilot' ) , alwaysShow : true }
62+ ] ;
5763 inputBox . activeItems = [ ] ;
5864 inputBox . selectedItems = [ ] ;
5965 inputBox . onDidAccept ( async ( ) => {
@@ -76,12 +82,18 @@ export function editQuery(namespace: string, queryName: string) {
7682 newValue . find ( ( query ) => query . label === queryName ) ! . query = newQuery ;
7783 await config . update ( QUERIES , newValue , target ) ;
7884 }
85+ inputBox . dispose ( ) ;
7986 } else if ( inputBox . selectedItems [ 0 ] === inputBox . items [ 1 ] ) {
8087 addNewQuery ( config , inspect , inputBox . value ) ;
88+ inputBox . dispose ( ) ;
8189 } else if ( inputBox . selectedItems [ 0 ] === inputBox . items [ 2 ] ) {
8290 openSettingsAtQuery ( config , inspect , queryName ) ;
91+ inputBox . dispose ( ) ;
92+ } else if ( inputBox . selectedItems [ 0 ] === inputBox . items [ 3 ] ) {
93+ inputBox . ignoreFocusOut = true ;
94+ await openCopilotForQuery ( inputBox . value ) ;
95+ inputBox . busy = false ;
8396 }
84- inputBox . dispose ( ) ;
8597 } ) ;
8698 inputBox . onDidHide ( ( ) => inputBox . dispose ( ) ) ;
8799 inputBox . show ( ) ;
@@ -151,4 +163,11 @@ async function openSettingsAtQuery(config: vscode.WorkspaceConfiguration, inspec
151163 editor . selection = new vscode . Selection ( position , position ) ;
152164 }
153165 }
166+ }
167+
168+ async function openCopilotForQuery ( currentQuery : string ) {
169+ const chatMessage = vscode . l10n . t ( 'I want to edit this GitHub search query: "{0}". Modify it so that it ' , currentQuery ) ;
170+
171+ // Open chat with the query pre-populated
172+ await vscode . commands . executeCommand ( commands . OPEN_CHAT , { query : chatMessage , isPartialQuery : true } ) ;
154173}
0 commit comments