File tree Expand file tree Collapse file tree 3 files changed +27
-4
lines changed
src/vs/workbench/contrib/inlineChat/browser Expand file tree Collapse file tree 3 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -202,8 +202,13 @@ export class InlineChatController implements IEditorContribution {
202
202
let widgetPosition : Position | undefined ;
203
203
if ( initialRender ) {
204
204
widgetPosition = this . _editor . getPosition ( ) ;
205
+ this . _zone . value . setMargins ( widgetPosition ) ;
205
206
} else {
206
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
+ }
207
212
}
208
213
this . _zone . value . show ( widgetPosition ) ;
209
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 @@ -795,13 +795,12 @@ export class InlineChatZoneWidget extends ZoneWidget {
795
795
super . show ( position , this . _computeHeightInLines ( ) ) ;
796
796
this . widget . focus ( ) ;
797
797
this . _ctxVisible . set ( true ) ;
798
- this . _setMargins ( position ) ;
799
798
}
800
799
801
- private _setMargins ( position : Position ) : void {
800
+ private _calculateIndentationWidth ( position : Position ) : number {
802
801
const viewModel = this . editor . _getViewModel ( ) ;
803
802
if ( ! viewModel ) {
804
- return ;
803
+ return 0 ;
805
804
}
806
805
const visibleRange = viewModel . getCompletelyVisibleViewRange ( ) ;
807
806
const startLineVisibleRange = visibleRange . startLineNumber ;
@@ -816,7 +815,16 @@ export class InlineChatZoneWidget extends ZoneWidget {
816
815
break ;
817
816
}
818
817
}
819
- 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
+ }
820
828
const info = this . editor . getLayoutInfo ( ) ;
821
829
const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
822
830
const marginWithIndentation = marginWithoutIndentation + this . _indentationWidth ;
You can’t perform that action at this time.
0 commit comments