6
6
import 'vs/css!./inlineChat' ;
7
7
import { DisposableStore , MutableDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
8
8
import { IActiveCodeEditor , ICodeEditor , IDiffEditorConstructionOptions } from 'vs/editor/browser/editorBrowser' ;
9
- import { EditorOption } from 'vs/editor/common/config/editorOptions' ;
10
- import { Range } from 'vs/editor/common/core/range' ;
9
+ import { EditorLayoutInfo , EditorOption } from 'vs/editor/common/config/editorOptions' ;
10
+ import { IRange , Range } from 'vs/editor/common/core/range' ;
11
11
import { localize } from 'vs/nls' ;
12
12
import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
13
13
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
@@ -744,15 +744,15 @@ export class InlineChatZoneWidget extends ZoneWidget {
744
744
protected override _doLayout ( heightInPixel : number ) : void {
745
745
746
746
const maxWidth = ! this . widget . showsAnyPreview ( ) ? 640 : Number . MAX_SAFE_INTEGER ;
747
- const width = Math . min ( maxWidth , this . _availableSpaceGivenIndentation ( ) ) ;
747
+ const width = Math . min ( maxWidth , this . _availableSpaceGivenIndentation ( this . _indentationWidth ) ) ;
748
748
this . _dimension = new Dimension ( width , heightInPixel ) ;
749
749
this . widget . domNode . style . width = `${ width } px` ;
750
750
this . widget . layout ( this . _dimension ) ;
751
751
}
752
752
753
- private _availableSpaceGivenIndentation ( ) : number {
753
+ private _availableSpaceGivenIndentation ( indentationWidth : number | undefined ) : number {
754
754
const info = this . editor . getLayoutInfo ( ) ;
755
- return info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth + ( this . _indentationWidth ?? 0 ) ) ;
755
+ return info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth + ( indentationWidth ?? 0 ) ) ;
756
756
}
757
757
758
758
private _computeHeightInLines ( ) : number {
@@ -773,6 +773,18 @@ export class InlineChatZoneWidget extends ZoneWidget {
773
773
this . _ctxVisible . set ( true ) ;
774
774
}
775
775
776
+ override _getWidth ( info : EditorLayoutInfo ) : number {
777
+ return info . width - info . minimap . minimapWidth ;
778
+ }
779
+
780
+ public updateBackgroundColor ( position : Position , selection : IRange ) {
781
+ if ( ! this . container ) {
782
+ return ;
783
+ }
784
+ const widgetLineNumber = position . lineNumber ;
785
+ this . container . classList . toggle ( 'inside-selection' , widgetLineNumber >= selection . startLineNumber && widgetLineNumber < selection . endLineNumber ) ;
786
+ }
787
+
776
788
private _calculateIndentationWidth ( position : Position ) : number {
777
789
const viewModel = this . editor . _getViewModel ( ) ;
778
790
if ( ! viewModel ) {
@@ -794,23 +806,25 @@ export class InlineChatZoneWidget extends ZoneWidget {
794
806
return this . editor . getOffsetForColumn ( indentationLineNumber ?? positionLine , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( positionLine ) ) ;
795
807
}
796
808
797
- setMargins ( position : Position , indentationWidth ?: number ) : void {
809
+ setContainerMargins ( ) : void {
810
+ if ( ! this . container ) {
811
+ return ;
812
+ }
813
+ const info = this . editor . getLayoutInfo ( ) ;
814
+ const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
815
+ this . container . style . marginLeft = `${ marginWithoutIndentation } px` ;
816
+ }
817
+
818
+ setWidgetMargins ( position : Position , indentationWidth ?: number ) : void {
798
819
if ( indentationWidth === undefined ) {
799
820
indentationWidth = this . _calculateIndentationWidth ( position ) ;
800
821
}
801
822
if ( this . _indentationWidth === indentationWidth ) {
802
823
return ;
803
824
}
804
- this . _indentationWidth = indentationWidth ;
805
- const info = this . editor . getLayoutInfo ( ) ;
806
- const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
807
- const marginWithIndentation = marginWithoutIndentation + this . _indentationWidth ;
808
- const isEnoughAvailableSpaceWithIndentation = this . _availableSpaceGivenIndentation ( ) > 400 ;
809
- this . _indentationWidth = isEnoughAvailableSpaceWithIndentation ? this . _indentationWidth : 0 ;
810
- const spaceLeft = isEnoughAvailableSpaceWithIndentation ? marginWithIndentation : marginWithoutIndentation ;
811
- const spaceRight = info . minimap . minimapWidth + info . verticalScrollbarWidth ;
812
- this . widget . domNode . style . marginLeft = `${ spaceLeft } px` ;
813
- this . widget . domNode . style . marginRight = `${ spaceRight } px` ;
825
+ this . _indentationWidth = this . _availableSpaceGivenIndentation ( indentationWidth ) > 400 ? indentationWidth : 0 ;
826
+ this . widget . domNode . style . marginLeft = `${ this . _indentationWidth } px` ;
827
+ this . widget . domNode . style . marginRight = `${ this . editor . getLayoutInfo ( ) . minimap . minimapWidth } px` ;
814
828
}
815
829
816
830
override hide ( ) : void {
0 commit comments