@@ -126,8 +126,8 @@ class MinimapOptions {
126126 this . minimapWidth = layoutInfo . minimapWidth ;
127127 this . minimapHeight = layoutInfo . height ;
128128
129- this . canvasInnerWidth = Math . max ( 1 , Math . floor ( pixelRatio * this . minimapWidth ) ) ;
130- this . canvasInnerHeight = Math . max ( 1 , Math . floor ( pixelRatio * this . minimapHeight ) ) ;
129+ this . canvasInnerWidth = Math . floor ( pixelRatio * this . minimapWidth ) ;
130+ this . canvasInnerHeight = Math . floor ( pixelRatio * this . minimapHeight ) ;
131131
132132 this . canvasOuterWidth = this . canvasInnerWidth / pixelRatio ;
133133 this . canvasOuterHeight = this . canvasInnerHeight / pixelRatio ;
@@ -657,16 +657,18 @@ export class Minimap extends ViewPart {
657657 this . _slider . setWidth ( this . _options . minimapWidth ) ;
658658 }
659659
660- private _getBuffer ( ) : ImageData {
660+ private _getBuffer ( ) : ImageData | null {
661661 if ( ! this . _buffers ) {
662- this . _buffers = new MinimapBuffers (
663- this . _canvas . domNode . getContext ( '2d' ) ! ,
664- this . _options . canvasInnerWidth ,
665- this . _options . canvasInnerHeight ,
666- this . _tokensColorTracker . getColor ( ColorId . DefaultBackground )
667- ) ;
662+ if ( this . _options . canvasInnerWidth > 0 && this . _options . canvasInnerHeight > 0 ) {
663+ this . _buffers = new MinimapBuffers (
664+ this . _canvas . domNode . getContext ( '2d' ) ! ,
665+ this . _options . canvasInnerWidth ,
666+ this . _options . canvasInnerHeight ,
667+ this . _tokensColorTracker . getColor ( ColorId . DefaultBackground )
668+ ) ;
669+ }
668670 }
669- return this . _buffers ! . getBuffer ( ) ;
671+ return this . _buffers ? this . _buffers . getBuffer ( ) : null ;
670672 }
671673
672674 private _onOptionsMaybeChanged ( ) : boolean {
@@ -906,7 +908,7 @@ export class Minimap extends ViewPart {
906908 canvasContext . fillRect ( x , y , width , height ) ;
907909 }
908910
909- private renderLines ( layout : MinimapLayout ) : RenderData {
911+ private renderLines ( layout : MinimapLayout ) : RenderData | null {
910912 const renderMinimap = this . _options . renderMinimap ;
911913 const charRenderer = this . _options . charRenderer ( ) ;
912914 const startLineNumber = layout . startLineNumber ;
@@ -923,6 +925,10 @@ export class Minimap extends ViewPart {
923925 // Oh well!! We need to repaint some lines...
924926
925927 const imageData = this . _getBuffer ( ) ;
928+ if ( ! imageData ) {
929+ // 0 width or 0 height canvas, nothing to do
930+ return null ;
931+ }
926932
927933 // Render untouched lines by using last rendered data.
928934 let [ _dirtyY1 , _dirtyY2 , needed ] = Minimap . _renderUntouchedLines (
0 commit comments