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 {
205
205
this . _zone . value . setMargins ( widgetPosition ) ;
206
206
} else {
207
207
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
+ }
208
212
}
209
213
this . _zone . value . show ( widgetPosition ) ;
210
214
}
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ export abstract class EditModeStrategy {
47
47
abstract hasFocus ( ) : boolean ;
48
48
49
49
abstract getWidgetPosition ( ) : Position | undefined ;
50
+
51
+ abstract needsMargin ( ) : boolean ;
50
52
}
51
53
52
54
export class PreviewStrategy extends EditModeStrategy {
@@ -145,6 +147,10 @@ export class PreviewStrategy extends EditModeStrategy {
145
147
hasFocus ( ) : boolean {
146
148
return this . _widget . hasFocus ( ) ;
147
149
}
150
+
151
+ needsMargin ( ) : boolean {
152
+ return true ;
153
+ }
148
154
}
149
155
150
156
class InlineDiffDecorations {
@@ -359,6 +365,10 @@ export class LiveStrategy extends EditModeStrategy {
359
365
return lastLineOfLocalEdits ? new Position ( lastLineOfLocalEdits , 1 ) : undefined ;
360
366
}
361
367
368
+ override needsMargin ( ) : boolean {
369
+ return Boolean ( this . _session . lastTextModelChanges . length ) ;
370
+ }
371
+
362
372
hasFocus ( ) : boolean {
363
373
return this . _widget . hasFocus ( ) ;
364
374
}
Original file line number Diff line number Diff line change @@ -797,10 +797,10 @@ export class InlineChatZoneWidget extends ZoneWidget {
797
797
this . _ctxVisible . set ( true ) ;
798
798
}
799
799
800
- public setMargins ( position : Position ) : void {
800
+ private _calculateIndentationWidth ( position : Position ) : number {
801
801
const viewModel = this . editor . _getViewModel ( ) ;
802
802
if ( ! viewModel ) {
803
- return ;
803
+ return 0 ;
804
804
}
805
805
const visibleRange = viewModel . getCompletelyVisibleViewRange ( ) ;
806
806
const startLineVisibleRange = visibleRange . startLineNumber ;
@@ -815,7 +815,16 @@ export class InlineChatZoneWidget extends ZoneWidget {
815
815
break ;
816
816
}
817
817
}
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
+ }
819
828
const info = this . editor . getLayoutInfo ( ) ;
820
829
const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
821
830
const marginWithIndentation = marginWithoutIndentation + this . _indentationWidth ;
You can’t perform that action at this time.
0 commit comments