overviewZoneManager.ts ×17

Frontier kind: Joint frontier

unlabeled · c_f5f2fc463e12

3 tests · 3583 LOC · 19 files · introduces 3 tests · 203 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges203 lines · 1 files
Tests
3 tests

Contains — complete concept membership

All code (extent)
498 ranges3583 lines · 19 files · Browse complete extent
All tests (intent)
3 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationuri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/editor/common/viewModel/overviewZoneManager.ts · 247 LOCviewModel/overviewZoneMa…src/vs/nls.ts · 244 LOCvs/nls.tscharCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…overviewZoneManager.test|title=Editor View - OverviewZoneManager pixel ratio 1, dom height 300|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/view/overviewZoneManager.test|title=Editor View - OverviewZoneManager pixel ratio 1, dom height 300|occurrence=1overviewZoneManager.test…overviewZoneManager.test|title=Editor View - OverviewZoneManager pixel ratio 1, dom height 600|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/view/overviewZoneManager.test|title=Editor View - OverviewZoneManager pixel ratio 1, dom height 600|occurrence=1overviewZoneManager.test…overviewZoneManager.test|title=Editor View - OverviewZoneManager pixel ratio 2, dom height 300|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/view/overviewZoneManager.test|title=Editor View - OverviewZoneManager pixel ratio 2, dom height 300|occurrence=1overviewZoneManager.test…Focused concept · overviewZoneManager.ts ×17 · 203 introduced LOCoverviewZoneManager.ts ×…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

3 tests introduced at this concept.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 203 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/viewModel/overviewZoneManager.ts 203 introduced LOC · 17 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- overviewZoneManager.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > const enum Constants {
7 > MINIMUM_HEIGHT = 4
8 > }
9 >
10 > export class ColorZone {
11 > _colorZoneBrand: void = undefined;
12 >
13 > public readonly from: number;
14 > public readonly to: number;
15 > public readonly colorId: number;
16 >
17 > constructor(from: number, to: number, colorId: number) {
18 > this.from = from | 0;
19 > this.to = to | 0;
20 > this.colorId = colorId | 0;
21 > }
22 >
23 > public static compare(a: ColorZone, b: ColorZone): number {
24 > if (a.colorId === b.colorId) {
25 if (a.from === b.from) {
26 return a.to - b.to;
28 return a.from - b.from;
29 }
30 > return a.colorId - b.colorId; overviewZoneManager.ts
31 > }
32 > }
33 >
34 > /**
35 > * A zone in the overview ruler
36 > */
37 > export class OverviewRulerZone {
38 > _overviewRulerZoneBrand: void = undefined;
39 >
40 > public readonly startLineNumber: number;
41 > public readonly endLineNumber: number;
42 > /**
43 > * If set to 0, the height in lines will be determined based on `endLineNumber`.
44 > */
45 > public readonly heightInLines: number;
46 > public readonly color: string;
47 >
48 > private _colorZone: ColorZone | null;
49 >
50 > constructor(
51 > startLineNumber: number,
52 > endLineNumber: number,
53 > heightInLines: number,
54 > color: string
55 > ) {
56 > this.startLineNumber = startLineNumber;
57 > this.endLineNumber = endLineNumber;
58 > this.heightInLines = heightInLines;
59 > this.color = color;
60 > this._colorZone = null;
61 > }
62 >
63 > public static compare(a: OverviewRulerZone, b: OverviewRulerZone): number {
64 > if (a.color === b.color) {
65 if (a.startLineNumber === b.startLineNumber) {
66 if (a.heightInLines === b.heightInLines) {
71 return a.startLineNumber - b.startLineNumber;
72 }
73 > return a.color < b.color ? -1 : 1; overviewZoneManager.ts
74 > }
75 >
76 > public setColorZone(colorZone: ColorZone): void {
77 > this._colorZone = colorZone;
78 > }
79 >
80 > public getColorZones(): ColorZone | null {
81 return this._colorZone;
82 }
84 >
85 > export class OverviewZoneManager {
86 >
87 > private readonly _getVerticalOffsetForLine: (lineNumber: number) => number;
88 > private _zones: OverviewRulerZone[];
89 > private _colorZonesInvalid: boolean;
90 > private _lineHeight: number;
91 > private _domWidth: number;
92 > private _domHeight: number;
93 > private _outerHeight: number;
94 > private _pixelRatio: number;
95 >
96 > private _lastAssignedId: number;
97 > private readonly _color2Id: { [color: string]: number };
98 > private readonly _id2Color: string[];
99 >
100 > constructor(getVerticalOffsetForLine: (lineNumber: number) => number) {
101 > this._getVerticalOffsetForLine = getVerticalOffsetForLine;
102 > this._zones = [];
103 > this._colorZonesInvalid = false;
104 > this._lineHeight = 0;
105 > this._domWidth = 0;
106 > this._domHeight = 0;
107 > this._outerHeight = 0;
108 > this._pixelRatio = 1;
109 >
110 > this._lastAssignedId = 0;
111 > this._color2Id = Object.create(null);
112 > this._id2Color = [];
113 > }
114 >
115 > public getId2Color(): string[] {
116 return this._id2Color;
117 }
119 > public setZones(newZones: OverviewRulerZone[]): void {
120 > this._zones = newZones;
121 > this._zones.sort(OverviewRulerZone.compare);
122 > }
123 >
124 > public setLineHeight(lineHeight: number): boolean {
125 > if (this._lineHeight === lineHeight) {
126 return false;
127 }
128 > this._lineHeight = lineHeight; overviewZoneManager.ts
129 > this._colorZonesInvalid = true;
130 > return true;
131 > }
132 >
133 > public setPixelRatio(pixelRatio: number): void {
134 > this._pixelRatio = pixelRatio;
135 > this._colorZonesInvalid = true;
136 > }
137 >
138 > public getDOMWidth(): number {
139 return this._domWidth;
140 }
142 > public getCanvasWidth(): number {
143 return this._domWidth * this._pixelRatio;
144 }
146 > public setDOMWidth(width: number): boolean {
147 > if (this._domWidth === width) {
148 return false;
149 }
150 > this._domWidth = width; overviewZoneManager.ts
151 > this._colorZonesInvalid = true;
152 > return true;
153 > }
154 >
155 > public getDOMHeight(): number {
156 return this._domHeight;
157 }
159 > public getCanvasHeight(): number {
160 > return this._domHeight * this._pixelRatio;
161 > }
162 >
163 > public setDOMHeight(height: number): boolean {
164 > if (this._domHeight === height) {
165 return false;
166 }
167 > this._domHeight = height; overviewZoneManager.ts
168 > this._colorZonesInvalid = true;
169 > return true;
170 > }
171 >
172 > public getOuterHeight(): number {
173 return this._outerHeight;
174 }
176 > public setOuterHeight(outerHeight: number): boolean {
177 > if (this._outerHeight === outerHeight) {
178 return false;
179 }
180 > this._outerHeight = outerHeight; overviewZoneManager.ts
181 > this._colorZonesInvalid = true;
182 > return true;
183 > }
184 >
185 > public resolveColorZones(): ColorZone[] {
186 > const colorZonesInvalid = this._colorZonesInvalid;
187 > const lineHeight = Math.floor(this._lineHeight);
188 > const totalHeight = Math.floor(this.getCanvasHeight());
189 > const outerHeight = Math.floor(this._outerHeight);
190 > const heightRatio = totalHeight / outerHeight;
191 > const halfMinimumHeight = Math.floor(Constants.MINIMUM_HEIGHT * this._pixelRatio / 2);
192 >
193 > const allColorZones: ColorZone[] = [];
194 > for (let i = 0, len = this._zones.length; i < len; i++) {
195 > const zone = this._zones[i];
196 >
197 > if (!colorZonesInvalid) {
198 const colorZone = zone.getColorZones();
199 if (colorZone) {
202 }
203 }
205 > const offset1 = this._getVerticalOffsetForLine(zone.startLineNumber);
206 > const offset2 = (
207 > zone.heightInLines === 0
208 > ? this._getVerticalOffsetForLine(zone.endLineNumber) + lineHeight
209 : offset1 + zone.heightInLines * lineHeight
211 >
212 > const y1 = Math.floor(heightRatio * offset1);
213 > const y2 = Math.floor(heightRatio * offset2);
214 >
215 > let ycenter = Math.floor((y1 + y2) / 2);
216 > let halfHeight = (y2 - ycenter);
217 >
218 > if (halfHeight < halfMinimumHeight) {
219 halfHeight = halfMinimumHeight;
220 }
222 > if (ycenter - halfHeight < 0) {
223 ycenter = halfHeight;
224 }
225 > if (ycenter + halfHeight > totalHeight) { overviewZoneManager.ts
226 > ycenter = totalHeight - halfHeight;
227 > }
228 >
229 > const color = zone.color;
230 > let colorId = this._color2Id[color];
231 > if (!colorId) {
232 > colorId = (++this._lastAssignedId);
233 > this._color2Id[color] = colorId;
234 > this._id2Color[colorId] = color;
235 > }
236 > const colorZone = new ColorZone(ycenter - halfHeight, ycenter + halfHeight, colorId);
237 >
238 > zone.setColorZone(colorZone);
239 > allColorZones.push(colorZone);
240 > }
241 >
242 > this._colorZonesInvalid = false;
243 >
244 > allColorZones.sort(ColorZone.compare);
245 > return allColorZones;
246 > }
247 > }