history.ts ×12

Frontier kind: Code frontier

unlabeled · c_662dca1837de

4 tests · 25840 LOC · 131 files · introduces 0 tests · 65 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges65 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3014 ranges25840 lines · 131 files · Browse complete extent
All tests (intent)
4 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.

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.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

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

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

src/vs/workbench/contrib/terminalContrib/history/common/history.ts 63 introduced LOC · 12 ranges

Open complete file

83
84 constructor(
85 > private readonly _storageDataKey: string, history.ts
86 > @IConfigurationService private readonly _configurationService: IConfigurationService,
87 > @IStorageService private readonly _storageService: IStorageService,
88 > ) {
89 > super();
90 >
91 > // Init cache
92 > this._entries = new LRUCache<string, T>(this._getHistoryLimit());
93 >
94 > // Listen for config changes to set history limit
95 > this._register(this._configurationService.onDidChangeConfiguration(e => {
96 if (e.affectsConfiguration(TerminalHistorySettingId.ShellIntegrationCommandHistory)) {
97 this._entries.limit = this._getHistoryLimit();
98 }
99 > })); history.ts
100 >
101 > // Listen to cache changes from other windows
102 > this._register(this._storageService.onDidChangeValue(StorageScope.APPLICATION, this._getTimestampStorageKey(), this._store)(() => {
103 > if (!this._isStale) {
104 > this._isStale = this._storageService.getNumber(this._getTimestampStorageKey(), StorageScope.APPLICATION, 0) !== this._timestamp;
105 > }
106 > }));
107 > }
108
109 add(key: string, value: T) {
110 > this._ensureUpToDate(); history.ts
111 > this._entries.set(key, value);
112 > this._saveState();
113 > }
114
115 remove(key: string) {
126
127 private _ensureUpToDate() {
128 > // Initial load history.ts
129 > if (!this._isReady) {
130 > this._loadState();
131 > this._isReady = true;
132 > }
133 >
134 > // React to stale cache caused by another window
135 > if (this._isStale) {
136 > // Since state is saved whenever the entries change, it's a safe assumption that no
137 > // merging of entries needs to happen, just loading the new state.
138 > this._entries.clear();
139 > this._loadState();
140 > this._isStale = false;
141 > }
142 > }
143
144 private _loadState() {
145 > this._timestamp = this._storageService.getNumber(this._getTimestampStorageKey(), StorageScope.APPLICATION, 0); history.ts
146 >
147 > // Load global entries plus
148 > const serialized = this._loadPersistedState();
149 > if (serialized) {
150 for (const entry of serialized.entries) {
151 this._entries.set(entry.key, entry.value);
152 }
153 }
154 > } history.ts
155
156 private _loadPersistedState(): ISerializedCache<T> | undefined {
157 > const raw = this._storageService.get(this._getEntriesStorageKey(), StorageScope.APPLICATION); history.ts
158 > if (raw === undefined || raw.length === 0) {
159 > return undefined;
160 > }
161 let serialized: ISerializedCache<T> | undefined = undefined;
162 try {
167 }
168 return serialized;
169 > } history.ts
170
171 private _saveState() {
172 > const serialized: ISerializedCache<T> = { entries: [] }; history.ts
173 > this._entries.forEach((value, key) => serialized.entries.push({ key, value }));
174 > this._storageService.store(this._getEntriesStorageKey(), JSON.stringify(serialized), StorageScope.APPLICATION, StorageTarget.MACHINE);
175 > this._timestamp = Date.now();
176 > this._storageService.store(this._getTimestampStorageKey(), this._timestamp, StorageScope.APPLICATION, StorageTarget.MACHINE);
177 > }
178
179 private _getHistoryLimit() {
180 > const historyLimit = this._configurationService.getValue(TerminalHistorySettingId.ShellIntegrationCommandHistory); history.ts
181 > return isNumber(historyLimit) ? historyLimit : Constants.DefaultHistoryLimit;
182 > }
183
184 private _getTimestampStorageKey() {
185 > return `${StorageKeys.Timestamp}.${this._storageDataKey}`; history.ts
186 > }
187
188 private _getEntriesStorageKey() {
189 > return `${StorageKeys.Entries}.${this._storageDataKey}`; history.ts
190 > }
191 }
192
src/vs/platform/instantiation/test/common/instantiationServiceMock.ts 2 introduced LOC · 1 range

Open complete file

38
39 public set<T>(service: ServiceIdentifier<T>, instance: T): T {
40 > return <T>this._serviceCollection.set(service, instance); instantiationServiceMock.ts
41 > }
42
43 public mock<T>(service: ServiceIdentifier<T>): T | sinon.SinonMock {