Skip to content

Commit

Permalink
Fix minimap decoration rendering on horizontal scroll, fixes #76128
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Macfarlane committed Jun 25, 2019
1 parent 53a1a35 commit bd7458a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/vs/editor/browser/viewParts/minimap/minimap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ export class Minimap extends ViewPart {

private _options: MinimapOptions;
private _lastRenderData: RenderData | null;
private _decorationsChanged: boolean = false;
private _renderDecorations: boolean = false;
private _buffers: MinimapBuffers | null;

constructor(context: ViewContext) {
Expand Down Expand Up @@ -650,6 +650,7 @@ export class Minimap extends ViewPart {
return true;
}
public onScrollChanged(e: viewEvents.ViewScrollChangedEvent): boolean {
this._renderDecorations = true;
return true;
}
public onTokensChanged(e: viewEvents.ViewTokensChangedEvent): boolean {
Expand All @@ -669,7 +670,7 @@ export class Minimap extends ViewPart {
}

public onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean {
this._decorationsChanged = true;
this._renderDecorations = true;
return true;
}

Expand Down Expand Up @@ -720,9 +721,8 @@ export class Minimap extends ViewPart {
}

private renderDecorations(layout: MinimapLayout) {
const scrollHasChanged = this._lastRenderData && !this._lastRenderData.scrollEquals(layout);
if (scrollHasChanged || this._decorationsChanged) {
this._decorationsChanged = false;
if (this._renderDecorations) {
this._renderDecorations = false;
const decorations = this._context.model.getDecorationsInViewport(new Range(layout.startLineNumber, 1, layout.endLineNumber, this._context.model.getLineMaxColumn(layout.endLineNumber)));

const { renderMinimap, canvasInnerWidth, canvasInnerHeight } = this._options;
Expand Down Expand Up @@ -790,11 +790,11 @@ export class Minimap extends ViewPart {
const x = lineIndexToXOffset[startColumn - 1];
const width = lineIndexToXOffset[endColumn - 1] - x;

this.renderADecoration(canvasContext, <ModelDecorationMinimapOptions>currentDecoration.options.minimap, x, y, width, height);
this.renderDecoration(canvasContext, <ModelDecorationMinimapOptions>currentDecoration.options.minimap, x, y, width, height);
}
}

private renderADecoration(canvasContext: CanvasRenderingContext2D, minimapOptions: ModelDecorationMinimapOptions, x: number, y: number, width: number, height: number) {
private renderDecoration(canvasContext: CanvasRenderingContext2D, minimapOptions: ModelDecorationMinimapOptions, x: number, y: number, width: number, height: number) {
const decorationColor = minimapOptions.getColor(this._context.theme);

canvasContext.fillStyle = decorationColor;
Expand Down

0 comments on commit bd7458a

Please sign in to comment.