Skip to content

Commit

Permalink
Fix overlay area for minimap slider
Browse files Browse the repository at this point in the history
Since minimap always render from a complete line, we have to recalculate sliderTop with align offset.
  • Loading branch information
xndcn committed Oct 12, 2020
1 parent 57dd72c commit b53e077
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/vs/editor/browser/viewParts/minimap/minimap.ts
Expand Up @@ -226,8 +226,7 @@ class MinimapLayout {
* Compute a desired `scrollPosition` such that the slider moves by `delta`.
*/
public getDesiredScrollTopFromDelta(delta: number): number {
const desiredSliderPosition = this.sliderTop + delta;
return Math.round(desiredSliderPosition / this._computedSliderRatio);
return Math.round(this.scrollTop + delta / this._computedSliderRatio);
}

public getDesiredScrollTopFromTouchLocation(pageY: number): number {
Expand Down Expand Up @@ -332,8 +331,9 @@ class MinimapLayout {
}

const endLineNumber = Math.min(lineCount, startLineNumber + minimapLinesFitting - 1);

return new MinimapLayout(scrollTop, scrollHeight, true, computedSliderRatio, sliderTop, sliderHeight, startLineNumber, endLineNumber);
const sliderTopAligned = (scrollTop / lineHeight - startLineNumber + 1) * minimapLineHeight / pixelRatio;

return new MinimapLayout(scrollTop, scrollHeight, true, computedSliderRatio, sliderTopAligned, sliderHeight, startLineNumber, endLineNumber);
}
}
}
Expand Down

0 comments on commit b53e077

Please sign in to comment.