@@ -763,14 +763,18 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
763
763
764
764
protected override _doLayout ( heightInPixel : number ) : void {
765
765
766
- const info = this . editor . getLayoutInfo ( ) ;
767
766
const maxWidth = ! this . widget . showsAnyPreview ( ) ? 640 : Number . MAX_SAFE_INTEGER ;
768
- const width = Math . min ( maxWidth , info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth + this . _indentationWidth ) ) ;
767
+ const width = Math . min ( maxWidth , this . _availableSpaceWithIndentation ( ) ) ;
769
768
this . _dimension = new Dimension ( width , heightInPixel ) ;
770
769
this . widget . domNode . style . width = `${ width } px` ;
771
770
this . widget . layout ( this . _dimension ) ;
772
771
}
773
772
773
+ private _availableSpaceWithIndentation ( ) : number {
774
+ const info = this . editor . getLayoutInfo ( ) ;
775
+ return info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth + this . _indentationWidth ) ;
776
+ }
777
+
774
778
private _computeHeightInLines ( ) : number {
775
779
const lineHeight = this . editor . getOption ( EditorOption . lineHeight ) ;
776
780
return this . widget . getHeight ( ) / lineHeight ;
@@ -809,7 +813,11 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
809
813
}
810
814
}
811
815
this . _indentationWidth = this . editor . getOffsetForColumn ( indentationLineNumber ?? endLineNumber , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( endLineNumber ) ) ;
812
- const spaceLeft = info . lineNumbersWidth + info . glyphMarginWidth + info . decorationsWidth + this . _indentationWidth ;
816
+ const marginWithoutIndentation = info . lineNumbersWidth + info . glyphMarginWidth + info . decorationsWidth ;
817
+ const marginWithIndentation = marginWithoutIndentation + this . _indentationWidth ;
818
+ const isEnoughAvailableSpaceWithIndentation = this . _availableSpaceWithIndentation ( ) > 400 ;
819
+ this . _indentationWidth = isEnoughAvailableSpaceWithIndentation ? this . _indentationWidth : 0 ;
820
+ const spaceLeft = isEnoughAvailableSpaceWithIndentation ? marginWithIndentation : marginWithoutIndentation ;
813
821
const spaceRight = info . minimap . minimapWidth + info . verticalScrollbarWidth ;
814
822
this . widget . domNode . style . marginLeft = `${ spaceLeft } px` ;
815
823
this . widget . domNode . style . marginRight = `${ spaceRight } px` ;
0 commit comments