@@ -18,7 +18,6 @@ export class EditDecorationManager {
18
18
private currentRemovedCodeDecorations : vscode . DecorationOptions [ ] = [ ]
19
19
private acceptHandler : ( ( ) => void ) | undefined
20
20
private rejectHandler : ( ( ) => void ) | undefined
21
- private disposables : vscode . Disposable [ ] = [ ]
22
21
23
22
constructor ( ) {
24
23
this . imageDecorationType = vscode . window . createTextEditorDecorationType ( {
@@ -28,6 +27,8 @@ export class EditDecorationManager {
28
27
this . removedCodeDecorationType = vscode . window . createTextEditorDecorationType ( {
29
28
backgroundColor : 'rgba(255, 0, 0, 0.2)' ,
30
29
} )
30
+
31
+ this . registerCommandHandlers ( )
31
32
}
32
33
33
34
/**
@@ -99,11 +100,9 @@ export class EditDecorationManager {
99
100
onAccept : ( ) => void ,
100
101
onReject : ( ) => void ,
101
102
originalCode : string ,
102
- newCode : string ,
103
- removedHighlights ?: vscode . DecorationOptions [ ]
103
+ newCode : string
104
104
) : void {
105
105
// Clear any existing decorations
106
- this . registerCommandHandlers ( )
107
106
this . clearDecorations ( editor )
108
107
109
108
// Set context to enable the Tab key handler
@@ -124,13 +123,8 @@ export class EditDecorationManager {
124
123
// Apply image decoration
125
124
editor . setDecorations ( this . imageDecorationType , [ this . currentImageDecoration ] )
126
125
127
- // Highlight removed parts with red background - use provided highlights if available
128
- if ( removedHighlights && removedHighlights . length > 0 ) {
129
- this . currentRemovedCodeDecorations = removedHighlights
130
- } else {
131
- // Fall back to line-level highlights if no char-level highlights provided
132
- this . currentRemovedCodeDecorations = this . highlightRemovedLines ( editor , originalCode , newCode )
133
- }
126
+ // Highlight removed lines with red background
127
+ this . currentRemovedCodeDecorations = this . highlightRemovedLines ( editor , originalCode , newCode )
134
128
editor . setDecorations ( this . removedCodeDecorationType , this . currentRemovedCodeDecorations )
135
129
}
136
130
@@ -152,30 +146,24 @@ export class EditDecorationManager {
152
146
*/
153
147
public registerCommandHandlers ( ) : void {
154
148
// Register Tab key handler for accepting suggestion
155
- const acceptDisposable = vscode . commands . registerCommand ( 'aws.amazonq.inline.acceptEdit' , ( ) => {
149
+ vscode . commands . registerCommand ( 'aws.amazonq.inline.acceptEdit' , ( ) => {
156
150
if ( this . acceptHandler ) {
157
151
this . acceptHandler ( )
158
152
}
159
153
} )
160
- this . disposables . push ( acceptDisposable )
161
154
162
155
// Register Esc key handler for rejecting suggestion
163
- const rejectDisposable = vscode . commands . registerCommand ( 'aws.amazonq.inline.rejectEdit' , ( ) => {
156
+ vscode . commands . registerCommand ( 'aws.amazonq.inline.rejectEdit' , ( ) => {
164
157
if ( this . rejectHandler ) {
165
158
this . rejectHandler ( )
166
159
}
167
160
} )
168
- this . disposables . push ( rejectDisposable )
169
161
}
170
162
171
163
/**
172
164
* Disposes resources
173
165
*/
174
166
public dispose ( ) : void {
175
- for ( const disposable of this . disposables ) {
176
- disposable . dispose ( )
177
- }
178
- this . disposables = [ ]
179
167
this . imageDecorationType . dispose ( )
180
168
this . removedCodeDecorationType . dispose ( )
181
169
}
0 commit comments