@@ -38,6 +38,7 @@ import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/se
38
38
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
39
39
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
40
40
import { Lazy } from 'vs/base/common/lazy' ;
41
+ import { Selection } from 'vs/editor/common/core/selection' ;
41
42
42
43
export const enum State {
43
44
CREATE_SESSION = 'CREATE_SESSION' ,
@@ -100,6 +101,7 @@ export class InlineChatController implements IEditorContribution {
100
101
private _activeSession ?: Session ;
101
102
private _strategy ?: EditModeStrategy ;
102
103
private _ignoreModelContentChanged = false ;
104
+ private _selection : Selection | undefined ;
103
105
104
106
constructor (
105
107
private readonly _editor : ICodeEditor ,
@@ -199,16 +201,32 @@ export class InlineChatController implements IEditorContribution {
199
201
assertType ( this . _strategy ) ;
200
202
assertType ( this . _editor . hasModel ( ) ) ;
201
203
204
+ const info = this . _editor . getLayoutInfo ( ) ;
205
+ const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
206
+ this . _zone . value . container ! . style . marginLeft = `${ marginWithoutIndentation } px` ;
207
+
202
208
let widgetPosition : Position | undefined ;
203
209
if ( initialRender ) {
210
+ this . _selection = this . _editor . getSelection ( ) ;
204
211
widgetPosition = this . _editor . getSelection ( ) . getEndPosition ( ) ;
205
212
this . _zone . value . setMargins ( widgetPosition ) ;
213
+ console . log ( 'widgetPosition : ' , widgetPosition ) ;
214
+ console . log ( 'selection : ' , this . _editor . getSelection ( ) ) ;
206
215
} else {
207
216
widgetPosition = this . _strategy . getWidgetPosition ( ) ?? this . _zone . value . position ?? this . _activeSession . wholeRange . value . getEndPosition ( ) ;
208
217
const needsMargin = this . _strategy . needsMargin ( ) ;
209
218
if ( ! needsMargin ) {
210
219
this . _zone . value . setMargins ( widgetPosition , 0 ) ;
211
220
}
221
+ // TODO: clean up
222
+ const widgetLineNumber = widgetPosition . lineNumber ;
223
+ if ( this . _selection && widgetLineNumber >= this . _selection . startLineNumber && widgetLineNumber < this . _selection . endLineNumber ) {
224
+ console . log ( 'this._zone.value.container : ' , this . _zone . value . container ) ;
225
+ this . _zone . value . container ! . style . backgroundColor = `var(--vscode-inlineChat-regionHighlight)` ;
226
+ }
227
+ console . log ( 'widgetPosition : ' , widgetPosition ) ;
228
+ console . log ( 'selection : ' , this . _editor . getSelection ( ) ) ;
229
+ console . log ( 'this._activeSession.wholeRange : ' , this . _activeSession . wholeRange ) ;
212
230
}
213
231
this . _zone . value . show ( widgetPosition ) ;
214
232
}
@@ -283,6 +301,7 @@ export class InlineChatController implements IEditorContribution {
283
301
range : this . _activeSession . wholeRange . value ,
284
302
options : InlineChatController . _decoBlock
285
303
} ] ) ;
304
+ console . log ( 'wholeRangeDecoration' , wholeRangeDecoration ) ;
286
305
this . _sessionStore . add ( toDisposable ( ( ) => wholeRangeDecoration . clear ( ) ) ) ;
287
306
288
307
this . _zone . value . widget . updateSlashCommands ( this . _activeSession . session . slashCommands ?? [ ] ) ;
0 commit comments