@@ -7,7 +7,7 @@ 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
9
import { 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' ;
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' ;
@@ -47,8 +47,8 @@ import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibil
47
47
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels' ;
48
48
import { ExpansionState } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession' ;
49
49
import { IdleValue } from 'vs/base/common/async' ;
50
- import * as aria from 'vs/base/browser/ui/aria/aria' ;
51
50
import { IMenuWorkbenchButtonBarOptions , MenuWorkbenchButtonBar } from 'vs/platform/actions/browser/buttonbar' ;
51
+ import * as aria from 'vs/base/browser/ui/aria/aria' ;
52
52
53
53
const defaultAriaLabel = localize ( 'aria-label' , "Inline Chat Input" ) ;
54
54
@@ -740,17 +740,17 @@ export class InlineChatZoneWidget extends ZoneWidget {
740
740
741
741
742
742
protected override _doLayout ( heightInPixel : number ) : void {
743
- console . log ( 'inside of _doLayout' ) ;
743
+
744
744
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 ) ) ;
746
746
this . _dimension = new Dimension ( width , heightInPixel ) ;
747
747
this . widget . domNode . style . width = `${ width } px` ;
748
748
this . widget . layout ( this . _dimension ) ;
749
749
}
750
750
751
- private _availableSpaceGivenIndentation ( ) : number {
751
+ private _availableSpaceGivenIndentation ( indentationWidth : number | undefined ) : number {
752
752
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 ) ) ;
754
754
}
755
755
756
756
private _computeHeightInLines ( ) : number {
@@ -771,6 +771,14 @@ export class InlineChatZoneWidget extends ZoneWidget {
771
771
this . _ctxVisible . set ( true ) ;
772
772
}
773
773
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
+
774
782
private _calculateIndentationWidth ( position : Position ) : number {
775
783
const viewModel = this . editor . _getViewModel ( ) ;
776
784
if ( ! viewModel ) {
@@ -792,21 +800,25 @@ export class InlineChatZoneWidget extends ZoneWidget {
792
800
return this . editor . getOffsetForColumn ( indentationLineNumber ?? positionLine , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( positionLine ) ) ;
793
801
}
794
802
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 {
796
813
if ( indentationWidth === undefined ) {
797
814
indentationWidth = this . _calculateIndentationWidth ( position ) ;
798
815
}
799
816
if ( this . _indentationWidth === indentationWidth ) {
800
817
return ;
801
818
}
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` ;
810
822
}
811
823
812
824
override hide ( ) : void {
0 commit comments