File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed
src/vs/workbench/contrib/inlineChat/browser Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,10 @@ export class InlineChatController implements IEditorContribution {
205205 this . _zone . value . setMargins ( widgetPosition ) ;
206206 } else {
207207 widgetPosition = this . _strategy . getWidgetPosition ( ) ?? this . _zone . value . position ?? this . _activeSession . wholeRange . value . getEndPosition ( ) ;
208+ const needsMargin = this . _strategy . needsMargin ( ) ;
209+ if ( ! needsMargin ) {
210+ this . _zone . value . setMargins ( widgetPosition , 0 ) ;
211+ }
208212 }
209213 this . _zone . value . show ( widgetPosition ) ;
210214 }
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ export abstract class EditModeStrategy {
4747 abstract hasFocus ( ) : boolean ;
4848
4949 abstract getWidgetPosition ( ) : Position | undefined ;
50+
51+ abstract needsMargin ( ) : boolean ;
5052}
5153
5254export class PreviewStrategy extends EditModeStrategy {
@@ -145,6 +147,10 @@ export class PreviewStrategy extends EditModeStrategy {
145147 hasFocus ( ) : boolean {
146148 return this . _widget . hasFocus ( ) ;
147149 }
150+
151+ needsMargin ( ) : boolean {
152+ return true ;
153+ }
148154}
149155
150156class InlineDiffDecorations {
@@ -359,6 +365,10 @@ export class LiveStrategy extends EditModeStrategy {
359365 return lastLineOfLocalEdits ? new Position ( lastLineOfLocalEdits , 1 ) : undefined ;
360366 }
361367
368+ override needsMargin ( ) : boolean {
369+ return Boolean ( this . _session . lastTextModelChanges . length ) ;
370+ }
371+
362372 hasFocus ( ) : boolean {
363373 return this . _widget . hasFocus ( ) ;
364374 }
Original file line number Diff line number Diff line change @@ -797,10 +797,10 @@ export class InlineChatZoneWidget extends ZoneWidget {
797797 this . _ctxVisible . set ( true ) ;
798798 }
799799
800- public setMargins ( position : Position ) : void {
800+ private _calculateIndentationWidth ( position : Position ) : number {
801801 const viewModel = this . editor . _getViewModel ( ) ;
802802 if ( ! viewModel ) {
803- return ;
803+ return 0 ;
804804 }
805805 const visibleRange = viewModel . getCompletelyVisibleViewRange ( ) ;
806806 const startLineVisibleRange = visibleRange . startLineNumber ;
@@ -815,7 +815,16 @@ export class InlineChatZoneWidget extends ZoneWidget {
815815 break ;
816816 }
817817 }
818- this . _indentationWidth = this . editor . getOffsetForColumn ( indentationLineNumber ?? positionLine , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( positionLine ) ) ;
818+ return this . editor . getOffsetForColumn ( indentationLineNumber ?? positionLine , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( positionLine ) ) ;
819+ }
820+
821+ setMargins ( position : Position , indentationWidth ?: number ) : void {
822+ if ( indentationWidth === undefined ) {
823+ indentationWidth = this . _calculateIndentationWidth ( position ) ;
824+ }
825+ if ( this . _indentationWidth === indentationWidth ) {
826+ return ;
827+ }
819828 const info = this . editor . getLayoutInfo ( ) ;
820829 const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
821830 const marginWithIndentation = marginWithoutIndentation + this . _indentationWidth ;
You can’t perform that action at this time.
0 commit comments