range.ts ×5

Frontier kind: Joint frontier

unlabeled · c_aeb575c87ba6

1 test · 3512 LOC · 20 files · introduces 1 test · 132 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges132 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
489 ranges3512 lines · 20 files · Browse complete extent
All tests (intent)
1 testBrowse 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/layout.ts · 166 LOCcommon/layout.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/range.ts · 60 LOCcommon/range.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/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…layout.test|title=Layout layout|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/layout.test|title=Layout layout|occurrence=1layout.test|title=Layout…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…Focused concept · range.ts ×5 · 132 introduced LOCrange.ts ×5

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.

1 test introduced at this concept.

Introduced code

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

2 files ranked by introduced lines: 132 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/base/common/layout.ts 103 introduced LOC · 3 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- layout.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 > import { Range } from './range.js';
7 >
8 > export interface IAnchor {
9 > x: number;
10 > y: number;
11 > width?: number;
12 > height?: number;
13 > }
14 >
15 > export const enum AnchorAlignment {
16 > LEFT, RIGHT
17 > }
18 >
19 > export const enum AnchorPosition {
20 > BELOW, ABOVE
21 > }
22 >
23 > export const enum AnchorAxisAlignment {
24 > VERTICAL, HORIZONTAL
25 > }
26 >
27 > interface IPosition {
28 > readonly top: number;
29 > readonly left: number;
30 > }
31 >
32 > interface ISize {
33 > readonly width: number;
34 > readonly height: number;
35 > }
36 >
37 > export interface IRect extends IPosition, ISize { }
38 >
39 > export const enum LayoutAnchorPosition {
40 > Before,
41 > After
42 > }
43 >
44 > export enum LayoutAnchorMode {
45 > AVOID,
46 > ALIGN
47 > }
48 >
49 > export interface ILayoutAnchor {
50 > offset: number;
51 > size: number;
52 > mode?: LayoutAnchorMode; // default: AVOID
53 > position: LayoutAnchorPosition;
54 > }
55 >
56 > export interface ILayoutResult {
57 > position: number;
58 > result: 'ok' | 'flipped' | 'overlap';
59 > }
60 >
61 > /**
62 > * Lays out a one dimensional view next to an anchor in a viewport.
63 > *
64 > * @returns The view offset within the viewport.
65 > */
66 > export function layout(viewportSize: number, viewSize: number, anchor: ILayoutAnchor): ILayoutResult {
67 > const layoutAfterAnchorBoundary = anchor.mode === LayoutAnchorMode.ALIGN ? anchor.offset : anchor.offset + anchor.size;
68 > const layoutBeforeAnchorBoundary = anchor.mode === LayoutAnchorMode.ALIGN ? anchor.offset + anchor.size : anchor.offset;
69 >
70 > if (anchor.position === LayoutAnchorPosition.Before) {
71 > if (viewSize <= viewportSize - layoutAfterAnchorBoundary) {
72 > return { position: layoutAfterAnchorBoundary, result: 'ok' }; // happy case, lay it out after the anchor
73 > }
74 >
75 > if (viewSize <= layoutBeforeAnchorBoundary) {
76 > return { position: layoutBeforeAnchorBoundary - viewSize, result: 'flipped' }; // ok case, lay it out before the anchor
77 > }
78
79 return { position: Math.max(viewportSize - viewSize, 0), result: 'overlap' }; // sad case, lay it over the anchor
80 > } else { layout.ts
81 > if (viewSize <= layoutBeforeAnchorBoundary) {
82 > return { position: layoutBeforeAnchorBoundary - viewSize, result: 'ok' }; // happy case, lay it out before the anchor
83 > }
84 >
85 > if (viewSize <= viewportSize - layoutAfterAnchorBoundary && layoutBeforeAnchorBoundary < viewSize / 2) {
86 > return { position: layoutAfterAnchorBoundary, result: 'flipped' }; // ok case, lay it out after the anchor
87 > }
88
89 return { position: 0, result: 'overlap' }; // sad case, lay it over the anchor
90 }
91 > } layout.ts
92 >
93 > interface ILayout2DOptions {
94 > readonly anchorAlignment?: AnchorAlignment; // default: left
95 > readonly anchorPosition?: AnchorPosition; // default: above
96 > readonly anchorAxisAlignment?: AnchorAxisAlignment; // default: vertical
97 > }
98 >
99 > export interface ILayout2DResult {
100 > top: number;
101 > left: number;
102 > bottom: number;
103 > right: number;
104 > anchorAlignment: AnchorAlignment;
105 > anchorPosition: AnchorPosition;
106 > }
107 >
108 > export function layout2d(viewport: IRect, view: ISize, anchor: IRect, options?: ILayout2DOptions): ILayout2DResult {
109 let anchorAlignment = options?.anchorAlignment ?? AnchorAlignment.LEFT;
110 let anchorPosition = options?.anchorPosition ?? AnchorPosition.BELOW;
src/vs/base/common/range.ts 29 introduced LOC · 5 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- range.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 > export interface IRange {
7 > start: number;
8 > end: number;
9 > }
10 >
11 > export interface IRangedGroup {
12 > range: IRange;
13 > size: number;
14 > }
15 >
16 > export namespace Range {
17 >
18 > /**
19 > * Returns the intersection between two ranges as a range itself.
20 > * Returns `{ start: 0, end: 0 }` if the intersection is empty.
21 > */
22 > export function intersect(one: IRange, other: IRange): IRange {
23 if (one.start >= other.end || other.start >= one.end) {
24 return { start: 0, end: 0 };
34 return { start, end };
35 }
36 > range.ts
37 > export function isEmpty(range: IRange): boolean {
38 return range.end - range.start <= 0;
39 }
40 > range.ts
41 > export function intersects(one: IRange, other: IRange): boolean {
42 return !isEmpty(intersect(one, other));
43 }
44 > range.ts
45 > export function relativeComplement(one: IRange, other: IRange): IRange[] {
46 const result: IRange[] = [];
47 const first = { start: one.start, end: Math.min(other.start, one.end) };
58 return result;
59 }
60 > } range.ts