@@ -38,6 +38,7 @@ import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/se
3838import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon' ;
3939import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
4040import { Lazy } from 'vs/base/common/lazy' ;
41+ import { Selection } from 'vs/editor/common/core/selection' ;
4142
4243export const enum State {
4344 CREATE_SESSION = 'CREATE_SESSION' ,
@@ -100,6 +101,7 @@ export class InlineChatController implements IEditorContribution {
100101 private _activeSession ?: Session ;
101102 private _strategy ?: EditModeStrategy ;
102103 private _ignoreModelContentChanged = false ;
104+ private _selection : Selection | undefined ;
103105
104106 constructor (
105107 private readonly _editor : ICodeEditor ,
@@ -199,16 +201,32 @@ export class InlineChatController implements IEditorContribution {
199201 assertType ( this . _strategy ) ;
200202 assertType ( this . _editor . hasModel ( ) ) ;
201203
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+
202208 let widgetPosition : Position | undefined ;
203209 if ( initialRender ) {
210+ this . _selection = this . _editor . getSelection ( ) ;
204211 widgetPosition = this . _editor . getSelection ( ) . getEndPosition ( ) ;
205212 this . _zone . value . setMargins ( widgetPosition ) ;
213+ console . log ( 'widgetPosition : ' , widgetPosition ) ;
214+ console . log ( 'selection : ' , this . _editor . getSelection ( ) ) ;
206215 } else {
207216 widgetPosition = this . _strategy . getWidgetPosition ( ) ?? this . _zone . value . position ?? this . _activeSession . wholeRange . value . getEndPosition ( ) ;
208217 const needsMargin = this . _strategy . needsMargin ( ) ;
209218 if ( ! needsMargin ) {
210219 this . _zone . value . setMargins ( widgetPosition , 0 ) ;
211220 }
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 ) ;
212230 }
213231 this . _zone . value . show ( widgetPosition ) ;
214232 }
@@ -283,6 +301,7 @@ export class InlineChatController implements IEditorContribution {
283301 range : this . _activeSession . wholeRange . value ,
284302 options : InlineChatController . _decoBlock
285303 } ] ) ;
304+ console . log ( 'wholeRangeDecoration' , wholeRangeDecoration ) ;
286305 this . _sessionStore . add ( toDisposable ( ( ) => wholeRangeDecoration . clear ( ) ) ) ;
287306
288307 this . _zone . value . widget . updateSlashCommands ( this . _activeSession . session . slashCommands ?? [ ] ) ;
0 commit comments