@@ -7,7 +7,7 @@ import 'vs/css!./inlineChat';
77import { DisposableStore , MutableDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
88import { IActiveCodeEditor , ICodeEditor , IDiffEditorConstructionOptions } from 'vs/editor/browser/editorBrowser' ;
99import { EditorOption } from 'vs/editor/common/config/editorOptions' ;
10- import { Range } from 'vs/editor/common/core/range' ;
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' ;
@@ -47,8 +47,8 @@ import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibil
4747import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels' ;
4848import { ExpansionState } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession' ;
4949import { IdleValue } from 'vs/base/common/async' ;
50- import * as aria from 'vs/base/browser/ui/aria/aria' ;
5150import { IMenuWorkbenchButtonBarOptions , MenuWorkbenchButtonBar } from 'vs/platform/actions/browser/buttonbar' ;
51+ import * as aria from 'vs/base/browser/ui/aria/aria' ;
5252
5353const defaultAriaLabel = localize ( 'aria-label' , "Inline Chat Input" ) ;
5454
@@ -740,17 +740,17 @@ export class InlineChatZoneWidget extends ZoneWidget {
740740
741741
742742 protected override _doLayout ( heightInPixel : number ) : void {
743- console . log ( 'inside of _doLayout' ) ;
743+
744744 const maxWidth = ! this . widget . showsAnyPreview ( ) ? 640 : Number . MAX_SAFE_INTEGER ;
745- const width = Math . min ( maxWidth , this . _availableSpaceGivenIndentation ( ) ) ;
745+ const width = Math . min ( maxWidth , this . _availableSpaceGivenIndentation ( this . _indentationWidth ) ) ;
746746 this . _dimension = new Dimension ( width , heightInPixel ) ;
747747 this . widget . domNode . style . width = `${ width } px` ;
748748 this . widget . layout ( this . _dimension ) ;
749749 }
750750
751- private _availableSpaceGivenIndentation ( ) : number {
751+ private _availableSpaceGivenIndentation ( indentationWidth : number | undefined ) : number {
752752 const info = this . editor . getLayoutInfo ( ) ;
753- return info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth + ( this . _indentationWidth ?? 0 ) ) ;
753+ return info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth + ( indentationWidth ?? 0 ) ) ;
754754 }
755755
756756 private _computeHeightInLines ( ) : number {
@@ -771,6 +771,14 @@ export class InlineChatZoneWidget extends ZoneWidget {
771771 this . _ctxVisible . set ( true ) ;
772772 }
773773
774+ public updateBackgroundColor ( position : Position , selection : IRange ) {
775+ if ( ! this . container ) {
776+ return ;
777+ }
778+ const widgetLineNumber = position . lineNumber ;
779+ this . container . classList . toggle ( 'inside-selection' , widgetLineNumber >= selection . startLineNumber && widgetLineNumber < selection . endLineNumber ) ;
780+ }
781+
774782 private _calculateIndentationWidth ( position : Position ) : number {
775783 const viewModel = this . editor . _getViewModel ( ) ;
776784 if ( ! viewModel ) {
@@ -792,21 +800,25 @@ export class InlineChatZoneWidget extends ZoneWidget {
792800 return this . editor . getOffsetForColumn ( indentationLineNumber ?? positionLine , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( positionLine ) ) ;
793801 }
794802
795- setMargins ( position : Position , indentationWidth ?: number ) : void {
803+ setContainerMargins ( ) : void {
804+ if ( ! this . container ) {
805+ return ;
806+ }
807+ const info = this . editor . getLayoutInfo ( ) ;
808+ const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
809+ this . container . style . marginLeft = `${ marginWithoutIndentation } px` ;
810+ }
811+
812+ setWidgetMargins ( position : Position , indentationWidth ?: number ) : void {
796813 if ( indentationWidth === undefined ) {
797814 indentationWidth = this . _calculateIndentationWidth ( position ) ;
798815 }
799816 if ( this . _indentationWidth === indentationWidth ) {
800817 return ;
801818 }
802- this . _indentationWidth = indentationWidth ;
803- const info = this . editor . getLayoutInfo ( ) ;
804- const isEnoughAvailableSpaceWithIndentation = this . _availableSpaceGivenIndentation ( ) > 400 ;
805- this . _indentationWidth = isEnoughAvailableSpaceWithIndentation ? this . _indentationWidth : 0 ;
806- const spaceLeft = isEnoughAvailableSpaceWithIndentation ? this . _indentationWidth : 0 ;
807- const spaceRight = info . minimap . minimapWidth ;
808- this . widget . domNode . style . marginLeft = `${ spaceLeft } px` ;
809- this . widget . domNode . style . marginRight = `${ spaceRight } px` ;
819+ this . _indentationWidth = this . _availableSpaceGivenIndentation ( indentationWidth ) > 400 ? indentationWidth : 0 ;
820+ this . widget . domNode . style . marginLeft = `${ this . _indentationWidth } px` ;
821+ this . widget . domNode . style . marginRight = `${ this . editor . getLayoutInfo ( ) . minimap . minimapWidth } px` ;
810822 }
811823
812824 override hide ( ) : void {
0 commit comments