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