@@ -787,32 +787,33 @@ export class InteractiveEditorZoneWidget extends ZoneWidget {
787
787
super . _relayout ( this . _computeHeightInLines ( ) ) ;
788
788
}
789
789
790
- override show ( selectionRange : Range ) : void {
791
- super . show ( selectionRange . getEndPosition ( ) , this . _computeHeightInLines ( ) ) ;
790
+ override show ( position : Position ) : void {
791
+ super . show ( position , this . _computeHeightInLines ( ) ) ;
792
792
this . widget . focus ( ) ;
793
793
this . _ctxVisible . set ( true ) ;
794
- this . _setMargins ( selectionRange ) ;
794
+ this . _setMargins ( position ) ;
795
795
}
796
796
797
- private _setMargins ( selectionRange : Range ) : void {
798
- const info = this . editor . getLayoutInfo ( ) ;
799
- const startLineNumber = selectionRange . getStartPosition ( ) . lineNumber ;
800
- const endLineNumber = selectionRange . getEndPosition ( ) . lineNumber ;
797
+ private _setMargins ( position : Position ) : void {
801
798
const viewModel = this . editor . _getViewModel ( ) ;
802
799
if ( ! viewModel ) {
803
800
return ;
804
801
}
802
+ const visibleRange = viewModel . getCompletelyVisibleViewRange ( ) ;
803
+ const startLineVisibleRange = visibleRange . startLineNumber ;
804
+ const positionLine = position . lineNumber ;
805
805
let indentationLineNumber ;
806
806
let indentationLevel ;
807
- for ( let lineNumber = endLineNumber ; lineNumber >= startLineNumber ; lineNumber -- ) {
807
+ for ( let lineNumber = positionLine ; lineNumber >= startLineVisibleRange ; lineNumber -- ) {
808
808
const currentIndentationLevel = viewModel . getLineFirstNonWhitespaceColumn ( lineNumber ) ;
809
809
if ( currentIndentationLevel !== 0 ) {
810
810
indentationLineNumber = lineNumber ;
811
811
indentationLevel = currentIndentationLevel ;
812
812
break ;
813
813
}
814
814
}
815
- this . _indentationWidth = this . editor . getOffsetForColumn ( indentationLineNumber ?? endLineNumber , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( endLineNumber ) ) ;
815
+ this . _indentationWidth = this . editor . getOffsetForColumn ( indentationLineNumber ?? positionLine , indentationLevel ?? viewModel . getLineFirstNonWhitespaceColumn ( positionLine ) ) ;
816
+ const info = this . editor . getLayoutInfo ( ) ;
816
817
const marginWithoutIndentation = info . glyphMarginWidth + info . decorationsWidth + info . lineNumbersWidth ;
817
818
const marginWithIndentation = marginWithoutIndentation + this . _indentationWidth ;
818
819
const isEnoughAvailableSpaceWithIndentation = this . _availableSpaceGivenIndentation ( ) > 400 ;
0 commit comments