Skip to content

Commit c57c8fc

Browse files
[cherry-pick] Keep the minimap size when the zoom level is slightly negative on high DPI screens (#347166)
Co-authored-by: vs-code-engineering[bot] <vs-code-engineering[bot]@users.noreply.github.com>
1 parent 0f2282b commit c57c8fc

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎src/vs/editor/common/config/editorOptions.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,14 +2826,15 @@ export class EditorLayoutInfoComputer extends ComputedEditorOption<EditorOption.
28262826
/**
28272827
* Computes the minimap scale in device pixels from the configured `editor.minimap.scale`.
28282828
* The configured scale is doubled on high DPI screens. Between a pixel ratio of 1 and 2,
2829-
* the scale grows with the pixel ratio, so that changing the zoom level only slightly
2830-
* doesn't change the minimap size abruptly.
2829+
* the scale grows with the pixel ratio. The tolerance keeps a pixel ratio slightly below
2830+
* a whole step (e.g. a slightly negative zoom level on a high DPI screen) at that step,
2831+
* instead of shrinking the minimap abruptly.
28312832
*/
28322833
private static _computeMinimapScale(configuredScale: number, pixelRatio: number): number {
28332834
if (pixelRatio >= 2) {
28342835
return Math.round(configuredScale * 2);
28352836
}
2836-
return Math.max(configuredScale, Math.floor(configuredScale * pixelRatio));
2837+
return Math.max(configuredScale, Math.floor(configuredScale * pixelRatio + 0.125));
28372838
}
28382839

28392840
private static _computeMinimapLayout(input: IMinimapLayoutInput, memory: ComputeOptionsMemory): EditorMinimapLayoutInfo {

‎src/vs/editor/test/browser/config/editorLayoutProvider.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
665665
}
666666

667667
test('issue #236999: the minimap scale does not jump when the pixel ratio crosses 2', () => {
668-
const pixelRatios = [1, 1.5, 1.99, 2, 2.5];
668+
const pixelRatios = [1, 1.25, 1.5, 1.75, 1.96, 1.9999998, 2, 2.5];
669669
const actual = [1, 2, 3].map(minimapScale => pixelRatios.map(pixelRatio => computeLayoutInfo({
670670
...minimapInput,
671671
lineNumbersDigitCount: 1,
@@ -674,9 +674,9 @@ suite('Editor ViewLayout - EditorLayoutProvider', () => {
674674
pixelRatio,
675675
}).minimap.minimapScale));
676676
assert.deepStrictEqual(actual, [
677-
[1, 1, 1, 2, 2],
678-
[2, 3, 3, 4, 4],
679-
[3, 4, 5, 6, 6],
677+
[1, 1, 1, 1, 2, 2, 2, 2],
678+
[2, 2, 3, 3, 4, 4, 4, 4],
679+
[3, 3, 4, 5, 6, 6, 6, 6],
680680
]);
681681
});
682682

0 commit comments

Comments
 (0)