@@ -21,7 +21,6 @@ export class EditDecorationManager {
21
21
private currentRemovedCodeDecorations : vscode . DecorationOptions [ ] = [ ]
22
22
private acceptHandler : ( ( ) => void ) | undefined
23
23
private rejectHandler : ( ( ) => void ) | undefined
24
- private disposables : vscode . Disposable [ ] = [ ]
25
24
26
25
constructor ( ) {
27
26
this . imageDecorationType = vscode . window . createTextEditorDecorationType ( {
@@ -31,6 +30,8 @@ export class EditDecorationManager {
31
30
this . removedCodeDecorationType = vscode . window . createTextEditorDecorationType ( {
32
31
backgroundColor : 'rgba(255, 0, 0, 0.2)' ,
33
32
} )
33
+
34
+ this . registerCommandHandlers ( )
34
35
}
35
36
36
37
/**
@@ -137,7 +138,6 @@ export class EditDecorationManager {
137
138
originalCodeHighlightRanges : Array < { line : number ; start : number ; end : number } >
138
139
) : void {
139
140
// Clear any existing decorations
140
- this . registerCommandHandlers ( )
141
141
this . clearDecorations ( editor )
142
142
143
143
// Set context to enable the Tab key handler
@@ -181,30 +181,24 @@ export class EditDecorationManager {
181
181
*/
182
182
public registerCommandHandlers ( ) : void {
183
183
// Register Tab key handler for accepting suggestion
184
- const acceptDisposable = vscode . commands . registerCommand ( 'aws.amazonq.inline.acceptEdit' , ( ) => {
184
+ vscode . commands . registerCommand ( 'aws.amazonq.inline.acceptEdit' , ( ) => {
185
185
if ( this . acceptHandler ) {
186
186
this . acceptHandler ( )
187
187
}
188
188
} )
189
- this . disposables . push ( acceptDisposable )
190
189
191
190
// Register Esc key handler for rejecting suggestion
192
- const rejectDisposable = vscode . commands . registerCommand ( 'aws.amazonq.inline.rejectEdit' , ( ) => {
191
+ vscode . commands . registerCommand ( 'aws.amazonq.inline.rejectEdit' , ( ) => {
193
192
if ( this . rejectHandler ) {
194
193
this . rejectHandler ( )
195
194
}
196
195
} )
197
- this . disposables . push ( rejectDisposable )
198
196
}
199
197
200
198
/**
201
199
* Disposes resources
202
200
*/
203
201
public dispose ( ) : void {
204
- for ( const disposable of this . disposables ) {
205
- disposable . dispose ( )
206
- }
207
- this . disposables = [ ]
208
202
this . imageDecorationType . dispose ( )
209
203
this . removedCodeDecorationType . dispose ( )
210
204
}
0 commit comments