@@ -13,7 +13,7 @@ import * as platform from 'vs/base/common/platform';
1313import * as strings from 'vs/base/common/strings' ;
1414import { ILine , RenderedLinesCollection } from 'vs/editor/browser/view/viewLayer' ;
1515import { PartFingerprint , PartFingerprints , ViewPart } from 'vs/editor/browser/view/viewPart' ;
16- import { RenderMinimap , EditorOption , MINIMAP_GUTTER_WIDTH , EditorLayoutInfoComputer , IComputedEditorOptions } from 'vs/editor/common/config/editorOptions' ;
16+ import { RenderMinimap , EditorOption , MINIMAP_GUTTER_WIDTH , EditorLayoutInfoComputer } from 'vs/editor/common/config/editorOptions' ;
1717import { Range } from 'vs/editor/common/core/range' ;
1818import { RGBA8 } from 'vs/editor/common/core/rgba' ;
1919import { IConfiguration , ScrollType } from 'vs/editor/common/editorCommon' ;
@@ -91,6 +91,8 @@ class MinimapOptions {
9191 */
9292 public readonly canvasOuterHeight : number ;
9393
94+ public readonly isSampling : boolean ;
95+ public readonly editorHeight : number ;
9496 public readonly fontScale : number ;
9597 public readonly minimapLineHeight : number ;
9698 public readonly minimapCharWidth : number ;
@@ -122,6 +124,8 @@ class MinimapOptions {
122124 this . canvasOuterWidth = layoutInfo . minimapCanvasOuterWidth ;
123125 this . canvasOuterHeight = layoutInfo . minimapCanvasOuterHeight ;
124126
127+ this . isSampling = layoutInfo . minimapIsSampling ;
128+ this . editorHeight = layoutInfo . height ;
125129 this . fontScale = layoutInfo . minimapScale ;
126130 this . minimapLineHeight = layoutInfo . minimapLineHeight ;
127131 this . minimapCharWidth = Constants . BASE_CHAR_WIDTH * this . fontScale ;
@@ -154,6 +158,8 @@ class MinimapOptions {
154158 && this . canvasInnerHeight === other . canvasInnerHeight
155159 && this . canvasOuterWidth === other . canvasOuterWidth
156160 && this . canvasOuterHeight === other . canvasOuterHeight
161+ && this . isSampling === other . isSampling
162+ && this . editorHeight === other . editorHeight
157163 && this . fontScale === other . fontScale
158164 && this . minimapLineHeight === other . minimapLineHeight
159165 && this . minimapCharWidth === other . minimapCharWidth
@@ -527,26 +533,24 @@ type SamplingStateEvent = SamplingStateLinesInsertedEvent | SamplingStateLinesDe
527533
528534class MinimapSamplingState {
529535
530- public static compute ( options : IComputedEditorOptions , modelLineCount : number , oldSamplingState : MinimapSamplingState | null ) : [ MinimapSamplingState | null , SamplingStateEvent [ ] ] {
531- const minimapOpts = options . get ( EditorOption . minimap ) ;
532- const layoutInfo = options . get ( EditorOption . layoutInfo ) ;
533- if ( ! minimapOpts . enabled || ! layoutInfo . minimapIsSampling ) {
536+ public static compute ( options : MinimapOptions , /* options: IComputedEditorOptions, */ viewLineCount : number , oldSamplingState : MinimapSamplingState | null ) : [ MinimapSamplingState | null , SamplingStateEvent [ ] ] {
537+ if ( options . renderMinimap === RenderMinimap . None || ! options . isSampling ) {
534538 return [ null , [ ] ] ;
535539 }
536540
537541 // ratio is intentionally not part of the layout to avoid the layout changing all the time
538542 // so we need to recompute it again...
539- const pixelRatio = options . get ( EditorOption . pixelRatio ) ;
540- const lineHeight = options . get ( EditorOption . lineHeight ) ;
541- const scrollBeyondLastLine = options . get ( EditorOption . scrollBeyondLastLine ) ;
543+ const pixelRatio = options . pixelRatio ;
544+ const lineHeight = options . lineHeight ;
545+ const scrollBeyondLastLine = options . scrollBeyondLastLine ;
542546 const { minimapLineCount } = EditorLayoutInfoComputer . computeContainedMinimapLineCount ( {
543- modelLineCount : modelLineCount ,
547+ viewLineCount : viewLineCount ,
544548 scrollBeyondLastLine : scrollBeyondLastLine ,
545- height : layoutInfo . height ,
549+ height : options . editorHeight ,
546550 lineHeight : lineHeight ,
547551 pixelRatio : pixelRatio
548552 } ) ;
549- const ratio = modelLineCount / minimapLineCount ;
553+ const ratio = viewLineCount / minimapLineCount ;
550554 const halfRatio = ratio / 2 ;
551555
552556 if ( ! oldSamplingState || oldSamplingState . minimapLines . length === 0 ) {
@@ -556,7 +560,7 @@ class MinimapSamplingState {
556560 for ( let i = 0 , lastIndex = minimapLineCount - 1 ; i < lastIndex ; i ++ ) {
557561 result [ i ] = Math . round ( i * ratio + halfRatio ) ;
558562 }
559- result [ minimapLineCount - 1 ] = modelLineCount ;
563+ result [ minimapLineCount - 1 ] = viewLineCount ;
560564 }
561565 return [ new MinimapSamplingState ( ratio , result ) , [ ] ] ;
562566 }
@@ -566,15 +570,15 @@ class MinimapSamplingState {
566570 let result : number [ ] = [ ] ;
567571 let oldIndex = 0 ;
568572 let oldDeltaLineCount = 0 ;
569- let minModelLineNumber = 1 ;
573+ let minViewLineNumber = 1 ;
570574 const MAX_EVENT_COUNT = 10 ; // generate at most 10 events, if there are more than 10 changes, just flush all previous data
571575 let events : SamplingStateEvent [ ] = [ ] ;
572576 let lastEvent : SamplingStateEvent | null = null ;
573577 for ( let i = 0 ; i < minimapLineCount ; i ++ ) {
574- const fromModelLineNumber = Math . max ( minModelLineNumber , Math . round ( i * ratio ) ) ;
575- const toModelLineNumber = Math . max ( fromModelLineNumber , Math . round ( ( i + 1 ) * ratio ) ) ;
578+ const fromViewLineNumber = Math . max ( minViewLineNumber , Math . round ( i * ratio ) ) ;
579+ const toViewLineNumber = Math . max ( fromViewLineNumber , Math . round ( ( i + 1 ) * ratio ) ) ;
576580
577- while ( oldIndex < oldLength && oldMinimapLines [ oldIndex ] < fromModelLineNumber ) {
581+ while ( oldIndex < oldLength && oldMinimapLines [ oldIndex ] < fromViewLineNumber ) {
578582 if ( events . length < MAX_EVENT_COUNT ) {
579583 const oldMinimapLineNumber = oldIndex + 1 + oldDeltaLineCount ;
580584 if ( lastEvent && lastEvent . type === 'deleted' && lastEvent . _oldIndex === oldIndex - 1 ) {
@@ -588,18 +592,18 @@ class MinimapSamplingState {
588592 oldIndex ++ ;
589593 }
590594
591- let selectedModelLineNumber : number ;
592- if ( oldIndex < oldLength && oldMinimapLines [ oldIndex ] <= toModelLineNumber ) {
595+ let selectedViewLineNumber : number ;
596+ if ( oldIndex < oldLength && oldMinimapLines [ oldIndex ] <= toViewLineNumber ) {
593597 // reuse the old sampled line
594- selectedModelLineNumber = oldMinimapLines [ oldIndex ] ;
598+ selectedViewLineNumber = oldMinimapLines [ oldIndex ] ;
595599 oldIndex ++ ;
596600 } else {
597601 if ( i === 0 ) {
598- selectedModelLineNumber = 1 ;
602+ selectedViewLineNumber = 1 ;
599603 } else if ( i + 1 === minimapLineCount ) {
600- selectedModelLineNumber = modelLineCount ;
604+ selectedViewLineNumber = viewLineCount ;
601605 } else {
602- selectedModelLineNumber = Math . round ( i * ratio + halfRatio ) ;
606+ selectedViewLineNumber = Math . round ( i * ratio + halfRatio ) ;
603607 }
604608 if ( events . length < MAX_EVENT_COUNT ) {
605609 const oldMinimapLineNumber = oldIndex + 1 + oldDeltaLineCount ;
@@ -613,8 +617,8 @@ class MinimapSamplingState {
613617 }
614618 }
615619
616- result [ i ] = selectedModelLineNumber ;
617- minModelLineNumber = selectedModelLineNumber ;
620+ result [ i ] = selectedViewLineNumber ;
621+ minViewLineNumber = selectedViewLineNumber ;
618622 }
619623
620624 if ( events . length < MAX_EVENT_COUNT ) {
@@ -743,7 +747,7 @@ export class Minimap extends ViewPart implements IMinimapModel {
743747 this . _minimapSelections = null ;
744748
745749 this . options = new MinimapOptions ( this . _context . configuration , this . _context . theme , this . tokensColorTracker ) ;
746- const [ samplingState , ] = MinimapSamplingState . compute ( this . _context . configuration . options , this . _context . model . getLineCount ( ) , null ) ;
750+ const [ samplingState , ] = MinimapSamplingState . compute ( this . options , this . _context . model . getLineCount ( ) , null ) ;
747751 this . _samplingState = samplingState ;
748752 this . _shouldCheckSampling = false ;
749753
@@ -787,6 +791,9 @@ export class Minimap extends ViewPart implements IMinimapModel {
787791 return false ;
788792 }
789793 public onFlushed ( e : viewEvents . ViewFlushedEvent ) : boolean {
794+ if ( this . _samplingState ) {
795+ this . _shouldCheckSampling = true ;
796+ }
790797 return this . _actual . onFlushed ( ) ;
791798 }
792799 public onLinesChanged ( e : viewEvents . ViewLinesChangedEvent ) : boolean {
@@ -898,7 +905,7 @@ export class Minimap extends ViewPart implements IMinimapModel {
898905 this . _minimapSelections = null ;
899906
900907 const wasSampling = Boolean ( this . _samplingState ) ;
901- const [ samplingState , events ] = MinimapSamplingState . compute ( this . _context . configuration . options , this . _context . model . getLineCount ( ) , this . _samplingState ) ;
908+ const [ samplingState , events ] = MinimapSamplingState . compute ( this . options , this . _context . model . getLineCount ( ) , this . _samplingState ) ;
902909 this . _samplingState = samplingState ;
903910
904911 if ( wasSampling && this . _samplingState ) {
0 commit comments