@@ -183,6 +183,7 @@ export class InteractiveEditorWidget {
183
183
private _isLayouting : boolean = false ;
184
184
private _preferredExpansionState : ExpansionState | undefined ;
185
185
private _expansionState : ExpansionState = ExpansionState . NOT_CROPPED ;
186
+ private _indentationWidth : number = 0 ;
186
187
187
188
constructor (
188
189
private readonly parentEditor : ICodeEditor ,
@@ -464,6 +465,14 @@ export class InteractiveEditorWidget {
464
465
this . _preferredExpansionState = expansionState ;
465
466
}
466
467
468
+ set indentationWidth ( indentationWidth : number ) {
469
+ this . _indentationWidth = indentationWidth ;
470
+ }
471
+
472
+ get indentationWidth ( ) : number {
473
+ return this . _indentationWidth ;
474
+ }
475
+
467
476
updateMarkdownMessage ( message : Node | undefined ) {
468
477
this . _elements . markdownMessage . classList . toggle ( 'hidden' , ! message ) ;
469
478
let expansionState : ExpansionState ;
@@ -764,7 +773,7 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
764
773
765
774
const info = this . editor . getLayoutInfo ( ) ;
766
775
const maxWidth = ! this . widget . showsAnyPreview ( ) ? 640 : Number . MAX_SAFE_INTEGER ;
767
- const width = Math . min ( maxWidth , info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth ) ) ;
776
+ const width = Math . min ( maxWidth , info . contentWidth - ( info . glyphMarginWidth + info . decorationsWidth + this . widget . indentationWidth ) ) ;
768
777
this . _dimension = new Dimension ( width , heightInPixel ) ;
769
778
this . widget . domNode . style . width = `${ width } px` ;
770
779
this . widget . layout ( this . _dimension ) ;
@@ -793,16 +802,19 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
793
802
const info = this . editor . getLayoutInfo ( ) ;
794
803
const startLineNumber = selectionRange . getStartPosition ( ) . lineNumber ;
795
804
const endLineNumber = selectionRange . getEndPosition ( ) . lineNumber ;
796
- let lineNumberForIndentation = endLineNumber ;
805
+ const viewModel = this . editor . _getViewModel ( ) ;
806
+ let indentationLineNumber = endLineNumber ;
807
+ let indentationLevel = viewModel ?. getLineFirstNonWhitespaceColumn ( endLineNumber ) ;
797
808
for ( let lineNumber = endLineNumber ; lineNumber >= startLineNumber ; lineNumber -- ) {
798
- const lineContent = this . editor . getModel ( ) ?. getLineContent ( lineNumber ) ;
799
- if ( lineContent && lineContent !== '' ) {
800
- lineNumberForIndentation = lineNumber ;
809
+ const currentIndentationLevel = viewModel ?. getLineFirstNonWhitespaceColumn ( lineNumber ) ;
810
+ if ( currentIndentationLevel && currentIndentationLevel !== 0 ) {
811
+ indentationLineNumber = lineNumber ;
812
+ indentationLevel = currentIndentationLevel ;
801
813
break ;
802
814
}
803
815
}
804
- const indentationLevel = this . editor . _getViewModel ( ) ?. getLineFirstNonWhitespaceColumn ( lineNumberForIndentation ) ;
805
- const spaceLeft = info . lineNumbersWidth + info . glyphMarginWidth + info . decorationsWidth + ( indentationLevel ? this . editor . getOffsetForColumn ( lineNumberForIndentation , indentationLevel ) : 0 ) ;
816
+ this . widget . indentationWidth = ( indentationLevel ? this . editor . getOffsetForColumn ( indentationLineNumber , indentationLevel ) : 0 ) ;
817
+ const spaceLeft = info . lineNumbersWidth + info . glyphMarginWidth + info . decorationsWidth + this . widget . indentationWidth ;
806
818
const spaceRight = info . minimap . minimapWidth + info . verticalScrollbarWidth ;
807
819
this . widget . domNode . style . marginLeft = `${ spaceLeft } px` ;
808
820
this . widget . domNode . style . marginRight = `${ spaceRight } px` ;
0 commit comments