@@ -43,6 +43,7 @@ import { ReferenceInlineProvider } from './service/referenceInlineProvider'
43
43
import { SecurityPanelViewProvider } from './views/securityPanelViewProvider'
44
44
import { disposeSecurityDiagnostic } from './service/diagnosticsProvider'
45
45
import { RecommendationHandler } from './service/recommendationHandler'
46
+ import { Commands } from '../shared/vscode/commands2'
46
47
47
48
const performance = globalThis . performance ?? require ( 'perf_hooks' ) . performance
48
49
@@ -100,7 +101,7 @@ export async function activate(context: ExtContext): Promise<void> {
100
101
/**
101
102
* Accept terms of service
102
103
*/
103
- vscode . commands . registerCommand ( 'aws.codeWhisperer.acceptTermsOfService' , async ( ) => {
104
+ Commands . register ( 'aws.codeWhisperer.acceptTermsOfService' , async ( ) => {
104
105
set ( CodeWhispererConstants . autoTriggerEnabledKey , true , context )
105
106
set ( CodeWhispererConstants . termsAcceptedKey , true , context )
106
107
await vscode . commands . executeCommand ( 'setContext' , CodeWhispererConstants . termsAcceptedKey , true )
@@ -119,14 +120,14 @@ export async function activate(context: ExtContext): Promise<void> {
119
120
/**
120
121
* Cancel terms of service
121
122
*/
122
- vscode . commands . registerCommand ( 'aws.codeWhisperer.cancelTermsOfService' , async ( ) => {
123
+ Commands . register ( 'aws.codeWhisperer.cancelTermsOfService' , async ( ) => {
123
124
set ( CodeWhispererConstants . autoTriggerEnabledKey , false , context )
124
125
await vscode . commands . executeCommand ( 'aws.codeWhisperer.refresh' )
125
126
} ) ,
126
127
/**
127
128
* Open Configuration
128
129
*/
129
- vscode . commands . registerCommand ( 'aws.codeWhisperer.configure' , async id => {
130
+ Commands . register ( 'aws.codeWhisperer.configure' , async id => {
130
131
if ( id === 'codewhisperer' ) {
131
132
await vscode . commands . executeCommand (
132
133
'workbench.action.openSettings' ,
@@ -149,13 +150,13 @@ export async function activate(context: ExtContext): Promise<void> {
149
150
// code scan
150
151
showSecurityScan . register ( context , securityPanelViewProvider , client ) ,
151
152
// manual trigger
152
- vscode . commands . registerCommand ( 'aws.codeWhisperer' , async ( ) => {
153
+ Commands . register ( { id : 'aws.codeWhisperer' , autoconnect : true } , async ( ) => {
153
154
invokeRecommendation ( vscode . window . activeTextEditor as vscode . TextEditor , client , await getConfigEntry ( ) )
154
155
} ) ,
155
156
/**
156
157
* On recommendation acceptance
157
158
*/
158
- vscode . commands . registerCommand (
159
+ Commands . register (
159
160
'aws.codeWhisperer.accept' ,
160
161
async (
161
162
range : vscode . Range ,
@@ -329,25 +330,25 @@ export async function activate(context: ExtContext): Promise<void> {
329
330
await InlineCompletion . instance . rejectRecommendation ( vscode . window . activeTextEditor )
330
331
}
331
332
} ) ,
332
- vscode . commands . registerCommand ( 'aws.codeWhisperer.rejectCodeSuggestion' , async e => {
333
+ Commands . register ( 'aws.codeWhisperer.rejectCodeSuggestion' , async e => {
333
334
if ( vscode . window . activeTextEditor )
334
335
await InlineCompletion . instance . rejectRecommendation ( vscode . window . activeTextEditor )
335
336
} ) ,
336
337
/**
337
338
* Recommendation navigation
338
339
*/
339
- vscode . commands . registerCommand ( 'aws.codeWhisperer.nextCodeSuggestion' , async ( ) => {
340
+ Commands . register ( 'aws.codeWhisperer.nextCodeSuggestion' , async ( ) => {
340
341
if ( vscode . window . activeTextEditor )
341
342
InlineCompletion . instance . navigateRecommendation ( vscode . window . activeTextEditor , true )
342
343
} ) ,
343
- vscode . commands . registerCommand ( 'aws.codeWhisperer.previousCodeSuggestion' , async ( ) => {
344
+ Commands . register ( 'aws.codeWhisperer.previousCodeSuggestion' , async ( ) => {
344
345
if ( vscode . window . activeTextEditor )
345
346
InlineCompletion . instance . navigateRecommendation ( vscode . window . activeTextEditor , false )
346
347
} ) ,
347
348
/**
348
349
* Recommendation acceptance
349
350
*/
350
- vscode . commands . registerCommand ( 'aws.codeWhisperer.acceptCodeSuggestion' , async ( ) => {
351
+ Commands . register ( 'aws.codeWhisperer.acceptCodeSuggestion' , async ( ) => {
351
352
if ( vscode . window . activeTextEditor )
352
353
await InlineCompletion . instance . acceptRecommendation ( vscode . window . activeTextEditor )
353
354
} )
0 commit comments