src/vs/base/common/navigator.ts

50 LOC · 50 covered · 0 uncovered · 15 ranges · 49 concepts · 7 introducers · 27 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filesrc/vs/base/common/history.ts · 298 LOCcommon/history.tshistory.test|title=History Navigator add resets the navigator to last|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator create sets the position after last|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator next on last element returns null and remains on last|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator previous on first element returns null and remains on first|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator previous returns previous element|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.ts ×1 · 1 introduced LOChistory.ts ×1history.test|title=History Navigator next returns object if the current position is not the last one|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator previous returns object if the current position is not the first one|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.ts ×1 · 3 introduced LOChistory.ts ×1history.test|title=History Navigator next returns null if the current position is the last one|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×1 · 2 introduced LOChistory.ts ×1history.test|title=History Navigator add reduces the input to limit|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator first returns first element|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator last returns last element|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator previous returns null if the current position is the first one|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.ts ×4 · 11 introduced LOChistory.ts ×4history.test|title=History Navigator create reduces the input to limit|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator adding an existing item changes the order|occurrence=1, history.test|title=History Navigator adding existing element changes the position|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator next returns next element|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.test|title=History Navigator 2 add - existing value|occurrence=1 · 0 introduced LOChistory.test|title=Histo…history.ts ×1 · 5 introduced LOChistory.ts ×1history.ts ×1 · 4 introduced LOChistory.ts ×1history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×1 · 1 introduced LOChistory.ts ×1history.ts ×1 · 1 introduced LOChistory.ts ×1history.ts ×1 · 5 introduced LOChistory.ts ×1history.ts ×1 · 6 introduced LOChistory.ts ×1history.ts ×2 · 9 introduced LOChistory.ts ×2history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×2 · 23 introduced LOChistory.ts ×2history.ts ×2 · 17 introduced LOChistory.ts ×2history.ts ×2 · 2 introduced LOChistory.ts ×2history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×1 · 6 introduced LOChistory.ts ×1history.ts ×1 · 5 introduced LOChistory.ts ×1history.ts ×1 · 6 introduced LOChistory.ts ×1history.ts ×2 · 3 introduced LOChistory.ts ×2history.ts ×2 · 6 introduced LOChistory.ts ×2history.ts ×6 · 34 introduced LOChistory.ts ×6history.ts ×1 · 2 introduced LOChistory.ts ×1navigator.ts ×1 · 2 introduced LOCnavigator.ts ×1history.ts ×6 · 27 introduced LOChistory.ts ×6history.ts ×1 · 2 introduced LOChistory.ts ×1history.ts ×2 · 2 introduced LOChistory.ts ×2history.ts ×31 · 135 introduced LOChistory.ts ×31history.test|title=History Navigator 2 add - existing value|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 add - existing value|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 add|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 add|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 constructor - capacity limit|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 constructor - capacity limit|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 constructor - duplicate values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 constructor - duplicate values|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 constructor - initial history is not empty|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 constructor - initial history is not empty|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 constructor|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 constructor|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 navigation|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 navigation|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 prepend|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 prepend|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 replaceLast - existing value|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 replaceLast - existing value|occurrence=1history.test|title=Histo…history.test|title=History Navigator 2 replaceLast|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator 2 replaceLast|occurrence=1history.test|title=Histo…history.test|title=History Navigator add reduces the input to limit|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator add reduces the input to limit|occurrence=1history.test|title=Histo…history.test|title=History Navigator add resets the navigator to last|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator add resets the navigator to last|occurrence=1history.test|title=Histo…history.test|title=History Navigator adding an existing item changes the order|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator adding an existing item changes the order|occurrence=1history.test|title=Histo…history.test|title=History Navigator adding existing element changes the position|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator adding existing element changes the position|occurrence=1history.test|title=Histo…history.test|title=History Navigator clear|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator clear|occurrence=1history.test|title=Histo…history.test|title=History Navigator create reduces the input to limit|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator create reduces the input to limit|occurrence=1history.test|title=Histo…history.test|title=History Navigator create sets the position after last|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator create sets the position after last|occurrence=1history.test|title=Histo…history.test|title=History Navigator first returns first element|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator first returns first element|occurrence=1history.test|title=Histo…history.test|title=History Navigator last returns last element|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator last returns last element|occurrence=1history.test|title=Histo…history.test|title=History Navigator next on last element returns null and remains on last|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator next on last element returns null and remains on last|occurrence=1history.test|title=Histo…history.test|title=History Navigator next returns next element|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator next returns next element|occurrence=1history.test|title=Histo…history.test|title=History Navigator next returns null if the current position is the last one|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator next returns null if the current position is the last one|occurrence=1history.test|title=Histo…history.test|title=History Navigator next returns object if the current position is not the last one|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator next returns object if the current position is not the last one|occurrence=1history.test|title=Histo…history.test|title=History Navigator previous on first element returns null and remains on first|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator previous on first element returns null and remains on first|occurrence=1history.test|title=Histo…history.test|title=History Navigator previous returns null if the current position is the first one|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator previous returns null if the current position is the first one|occurrence=1history.test|title=Histo…history.test|title=History Navigator previous returns object if the current position is not the first one|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator previous returns object if the current position is not the first one|occurrence=1history.test|title=Histo…history.test|title=History Navigator previous returns previous element|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/history.test|title=History Navigator previous returns previous element|occurrence=1history.test|title=Histo…Focused file · src/vs/base/common/navigator.ts · 50 LOCcommon/navigator.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- history.ts ×31
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 INavigator<T> {
7 > current(): T | null;
8 > previous(): T | null;
9 > first(): T | null;
10 > last(): T | null;
11 > next(): T | null;
12 > }
13 >
14 > export class ArrayNavigator<T> implements INavigator<T> {
15 >
16 > constructor(
17 > private readonly items: readonly T[], history.ts ×6
18 > protected start: number = 0,
19 > protected end: number = items.length,
20 > protected index = start - 1
21 > ) { }
23 > current(): T | null {
24 > if (this.index === this.start - 1 || this.index === this.end) { history.ts ×6
25 > return null; navigator.ts ×1
26 > }
28 > return this.items[this.index];
29 > }
31 > next(): T | null {
32 > this.index = Math.min(this.index + 1, this.end); history.ts ×1
33 > return this.current();
34 > }
36 > previous(): T | null {
37 > this.index = Math.max(this.index - 1, this.start - 1); history.ts ×1
38 > return this.current();
39 > }
41 > first(): T | null {
42 > this.index = this.start; history.ts ×1
43 > return this.current();
44 > }
46 > last(): T | null {
47 > this.index = this.end - 1; history.ts ×1
48 > return this.current();
49 > }