66import 'vs/css!./inlineChat' ;
77import { DisposableStore , MutableDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
88import { 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' ;
1111import { localize } from 'vs/nls' ;
1212import { IContextKey , IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
1313import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation' ;
@@ -744,15 +744,15 @@ export class InlineChatZoneWidget extends ZoneWidget {
744744 protected override _doLayout ( heightInPixel : number ) : void {
745745
746746 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 ) ) ;
748748 this . _dimension = new Dimension ( width , heightInPixel ) ;
749749 this . widget . domNode . style . width = `${ width } px` ;
750750 this . widget . layout ( this . _dimension ) ;
751751 }
752752
753- private _availableSpaceGivenIndentation ( ) : number {
753+ private _availableSpaceGivenIndentation ( indentationWidth : number | undefined ) : number {
754754 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 ) ) ;
756756 }
757757
758758 private _computeHeightInLines ( ) : number {
@@ -773,6 +773,18 @@ export class InlineChatZoneWidget extends ZoneWidget {
773773 this . _ctxVisible . set ( true ) ;
774774 }
775775
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+
776788 private _calculateIndentationWidth ( position : Position ) : number {
777789 const viewModel = this . editor . _getViewModel ( ) ;
778790 if ( ! viewModel ) {
@@ -794,23 +806,25 @@ export class InlineChatZoneWidget extends ZoneWidget {
794806 return this . editor . getOffsetForColumn ( indentationLineNumber ?? positionLine , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( positionLine ) ) ;
795807 }
796808
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 {
798819 if ( indentationWidth === undefined ) {
799820 indentationWidth = this . _calculateIndentationWidth ( position ) ;
800821 }
801822 if ( this . _indentationWidth === indentationWidth ) {
802823 return ;
803824 }
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` ;
814828 }
815829
816830 override hide ( ) : void {
0 commit comments