Skip to content

Commit 86f3a07

Browse files
author
Benjamin Pasero
committed
debt - rename platform/history => workspacesHistory
1 parent bb8416a commit 86f3a07

17 files changed

Lines changed: 50 additions & 50 deletions

File tree

src/vs/code/electron-main/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import { GlobalStorageDatabaseChannel } from 'vs/platform/storage/node/storageIp
6464
import { startsWith } from 'vs/base/common/strings';
6565
import { BackupMainService } from 'vs/platform/backup/electron-main/backupMainService';
6666
import { IBackupMainService } from 'vs/platform/backup/electron-main/backup';
67-
import { HistoryMainService, IHistoryMainService } from 'vs/platform/history/electron-main/historyMainService';
67+
import { WorkspacesHistoryMainService, IWorkspacesHistoryMainService } from 'vs/platform/workspaces/electron-main/workspacesHistoryMainService';
6868
import { URLService } from 'vs/platform/url/node/urlService';
6969
import { WorkspacesMainService, IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
7070
import { statSync } from 'fs';
@@ -466,7 +466,7 @@ export class CodeApplication extends Disposable {
466466
const backupMainService = new BackupMainService(this.environmentService, this.configurationService, this.logService);
467467
services.set(IBackupMainService, backupMainService);
468468

469-
services.set(IHistoryMainService, new SyncDescriptor(HistoryMainService));
469+
services.set(IWorkspacesHistoryMainService, new SyncDescriptor(WorkspacesHistoryMainService));
470470
services.set(IURLService, new SyncDescriptor(URLService));
471471
services.set(IWorkspacesMainService, new SyncDescriptor(WorkspacesMainService));
472472

src/vs/code/electron-main/windows.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
2424
import product from 'vs/platform/product/common/product';
2525
import { ITelemetryService, ITelemetryData } from 'vs/platform/telemetry/common/telemetry';
2626
import { IWindowsMainService, IOpenConfiguration, IWindowsCountChangedEvent, ICodeWindow, IWindowState as ISingleWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows';
27-
import { IRecent } from 'vs/platform/history/common/history';
28-
import { IHistoryMainService } from 'vs/platform/history/electron-main/historyMainService';
27+
import { IRecent } from 'vs/platform/workspaces/common/workspacesHistory';
28+
import { IWorkspacesHistoryMainService } from 'vs/platform/workspaces/electron-main/workspacesHistoryMainService';
2929
import { IProcessEnvironment, isMacintosh, isWindows } from 'vs/base/common/platform';
3030
import { IWorkspaceIdentifier, WORKSPACE_FILTER, isSingleFolderWorkspaceIdentifier, hasWorkspaceFileExtension, IEnterWorkspaceResult } from 'vs/platform/workspaces/common/workspaces';
3131
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
@@ -192,7 +192,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
192192
@IBackupMainService private readonly backupMainService: IBackupMainService,
193193
@ITelemetryService private readonly telemetryService: ITelemetryService,
194194
@IConfigurationService private readonly configurationService: IConfigurationService,
195-
@IHistoryMainService private readonly historyMainService: IHistoryMainService,
195+
@IWorkspacesHistoryMainService private readonly workspacesHistoryMainService: IWorkspacesHistoryMainService,
196196
@IWorkspacesMainService private readonly workspacesMainService: IWorkspacesMainService,
197197
@IInstantiationService private readonly instantiationService: IInstantiationService
198198
) {
@@ -508,7 +508,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
508508
recents.push({ label: pathToOpen.label, fileUri: pathToOpen.fileUri });
509509
}
510510
}
511-
this.historyMainService.addRecentlyOpened(recents);
511+
this.workspacesHistoryMainService.addRecentlyOpened(recents);
512512
}
513513

514514
// If we got started with --wait from the CLI, we need to signal to the outside when the window
@@ -1128,7 +1128,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
11281128
}
11291129
} catch (error) {
11301130
const fileUri = URI.file(candidate);
1131-
this.historyMainService.removeFromRecentlyOpened([fileUri]); // since file does not seem to exist anymore, remove from recent
1131+
this.workspacesHistoryMainService.removeFromRecentlyOpened([fileUri]); // since file does not seem to exist anymore, remove from recent
11321132

11331133
// assume this is a file that does not yet exist
11341134
if (options && options.ignoreFileNotFound) {
@@ -1589,7 +1589,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
15891589
private doEnterWorkspace(win: ICodeWindow, result: IEnterWorkspaceResult): IEnterWorkspaceResult {
15901590

15911591
// Mark as recently opened
1592-
this.historyMainService.addRecentlyOpened([{ workspace: result.workspace }]);
1592+
this.workspacesHistoryMainService.addRecentlyOpened([{ workspace: result.workspace }]);
15931593

15941594
// Trigger Eevent to indicate load of workspace into window
15951595
this._onWindowReady.fire(win);

src/vs/platform/electron/electron-main/electronMainService.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import { IElectronService } from 'vs/platform/electron/node/electron';
1313
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
1414
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
1515
import { AddFirstParameterToFunctions } from 'vs/base/common/types';
16-
import { IHistoryMainService } from 'vs/platform/history/electron-main/historyMainService';
17-
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
16+
import { IWorkspacesHistoryMainService } from 'vs/platform/workspaces/electron-main/workspacesHistoryMainService';
17+
import { IRecentlyOpened, IRecent } from 'vs/platform/workspaces/common/workspacesHistory';
1818
import { URI } from 'vs/base/common/uri';
1919

2020
export class ElectronMainService implements AddFirstParameterToFunctions<IElectronService, Promise<any> /* only methods, not events */, number /* window ID */> {
@@ -25,7 +25,7 @@ export class ElectronMainService implements AddFirstParameterToFunctions<IElectr
2525
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
2626
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
2727
@IEnvironmentService private readonly environmentService: IEnvironmentService,
28-
@IHistoryMainService private readonly historyMainService: IHistoryMainService
28+
@IWorkspacesHistoryMainService private readonly workspacesHistoryMainService: IWorkspacesHistoryMainService
2929
) {
3030
}
3131

@@ -333,27 +333,27 @@ export class ElectronMainService implements AddFirstParameterToFunctions<IElectr
333333

334334
//#region Workspaces History
335335

336-
readonly onRecentlyOpenedChange = this.historyMainService.onRecentlyOpenedChange;
336+
readonly onRecentlyOpenedChange = this.workspacesHistoryMainService.onRecentlyOpenedChange;
337337

338338
async getRecentlyOpened(windowId: number): Promise<IRecentlyOpened> {
339339
const window = this.windowsMainService.getWindowById(windowId);
340340
if (window) {
341-
return this.historyMainService.getRecentlyOpened(window.config.workspace, window.config.folderUri, window.config.filesToOpenOrCreate);
341+
return this.workspacesHistoryMainService.getRecentlyOpened(window.config.workspace, window.config.folderUri, window.config.filesToOpenOrCreate);
342342
}
343343

344-
return this.historyMainService.getRecentlyOpened();
344+
return this.workspacesHistoryMainService.getRecentlyOpened();
345345
}
346346

347347
async addRecentlyOpened(windowId: number, recents: IRecent[]): Promise<void> {
348-
return this.historyMainService.addRecentlyOpened(recents);
348+
return this.workspacesHistoryMainService.addRecentlyOpened(recents);
349349
}
350350

351351
async removeFromRecentlyOpened(windowId: number, paths: URI[]): Promise<void> {
352-
return this.historyMainService.removeFromRecentlyOpened(paths);
352+
return this.workspacesHistoryMainService.removeFromRecentlyOpened(paths);
353353
}
354354

355355
async clearRecentlyOpened(windowId: number): Promise<void> {
356-
return this.historyMainService.clearRecentlyOpened();
356+
return this.workspacesHistoryMainService.clearRecentlyOpened();
357357
}
358358

359359
//#endregion

src/vs/platform/electron/node/electron.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { MessageBoxOptions, MessageBoxReturnValue, OpenDevToolsOptions, SaveDial
88
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
99
import { INativeOpenDialogOptions, IWindowOpenable, IOpenInWindowOptions, IOpenedWindow, IOpenEmptyWindowOptions } from 'vs/platform/windows/common/windows';
1010
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
11-
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
11+
import { IRecentlyOpened, IRecent } from 'vs/platform/workspaces/common/workspacesHistory';
1212
import { URI } from 'vs/base/common/uri';
1313
import { ParsedArgs } from 'vscode-minimist';
1414
import { IProcessEnvironment } from 'vs/base/common/platform';

src/vs/platform/menubar/electron-main/menubar.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { RunOnceScheduler } from 'vs/base/common/async';
1616
import { ILogService } from 'vs/platform/log/common/log';
1717
import { mnemonicMenuLabel as baseMnemonicLabel } from 'vs/base/common/labels';
1818
import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows';
19-
import { IHistoryMainService } from 'vs/platform/history/electron-main/historyMainService';
19+
import { IWorkspacesHistoryMainService } from 'vs/platform/workspaces/electron-main/workspacesHistoryMainService';
2020
import { IMenubarData, IMenubarKeybinding, MenubarMenuItem, isMenubarMenuItemSeparator, isMenubarMenuItemSubmenu, isMenubarMenuItemAction, IMenubarMenu, isMenubarMenuItemUriAction } from 'vs/platform/menubar/node/menubar';
2121
import { URI } from 'vs/base/common/uri';
2222
import { IStateService } from 'vs/platform/state/common/state';
@@ -66,7 +66,7 @@ export class Menubar {
6666
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
6767
@IEnvironmentService private readonly environmentService: IEnvironmentService,
6868
@ITelemetryService private readonly telemetryService: ITelemetryService,
69-
@IHistoryMainService private readonly historyMainService: IHistoryMainService,
69+
@IWorkspacesHistoryMainService private readonly workspacesHistoryMainService: IWorkspacesHistoryMainService,
7070
@IStateService private readonly stateService: IStateService,
7171
@ILifecycleMainService private readonly lifecycleMainService: ILifecycleMainService,
7272
@ILogService private readonly logService: ILogService
@@ -115,7 +115,7 @@ export class Menubar {
115115
this.fallbackMenuHandlers['workbench.action.openWorkspace'] = (menuItem, win, event) => this.windowsMainService.pickWorkspaceAndOpen({ forceNewWindow: this.isOptionClick(event), telemetryExtraData: { from: telemetryFrom } });
116116

117117
// Recent Menu Items
118-
this.fallbackMenuHandlers['workbench.action.clearRecentFiles'] = () => this.historyMainService.clearRecentlyOpened();
118+
this.fallbackMenuHandlers['workbench.action.clearRecentFiles'] = () => this.workspacesHistoryMainService.clearRecentlyOpened();
119119

120120
// Help Menu Items
121121
const twitterUrl = product.twitterUrl;
@@ -488,7 +488,7 @@ export class Menubar {
488488
}).length > 0;
489489

490490
if (!success) {
491-
this.historyMainService.removeFromRecentlyOpened([revivedUri]);
491+
this.workspacesHistoryMainService.removeFromRecentlyOpened([revivedUri]);
492492
}
493493
}
494494
}, false));
File renamed without changes.

src/vs/platform/history/common/historyStorage.ts renamed to src/vs/platform/workspaces/common/workspacesHistoryStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55
import { UriComponents, URI } from 'vs/base/common/uri';
6-
import { IRecentlyOpened, isRecentFolder } from 'vs/platform/history/common/history';
6+
import { IRecentlyOpened, isRecentFolder } from 'vs/platform/workspaces/common/workspacesHistory';
77
import { ILogService } from 'vs/platform/log/common/log';
88

99
interface ISerializedRecentlyOpened {

src/vs/platform/history/electron-main/historyMainService.ts renamed to src/vs/platform/workspaces/electron-main/workspacesHistoryMainService.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
1414
import { isWindows, isMacintosh } from 'vs/base/common/platform';
1515
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
1616
import { IWorkspacesMainService } from 'vs/platform/workspaces/electron-main/workspacesMainService';
17-
import { IRecentlyOpened, isRecentWorkspace, isRecentFolder, IRecent, isRecentFile, IRecentFolder, IRecentWorkspace, IRecentFile } from 'vs/platform/history/common/history';
17+
import { IRecentlyOpened, isRecentWorkspace, isRecentFolder, IRecent, isRecentFile, IRecentFolder, IRecentWorkspace, IRecentFile } from 'vs/platform/workspaces/common/workspacesHistory';
1818
import { ThrottledDelayer } from 'vs/base/common/async';
1919
import { isEqual as areResourcesEqual, dirname, originalFSPath, basename } from 'vs/base/common/resources';
2020
import { URI } from 'vs/base/common/uri';
2121
import { Schemas } from 'vs/base/common/network';
2222
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
2323
import { getSimpleWorkspaceLabel } from 'vs/platform/label/common/label';
24-
import { toStoreData, restoreRecentlyOpened, RecentlyOpenedStorageData } from 'vs/platform/history/common/historyStorage';
24+
import { toStoreData, restoreRecentlyOpened, RecentlyOpenedStorageData } from 'vs/platform/workspaces/common/workspacesHistoryStorage';
2525
import { exists } from 'vs/base/node/pfs';
2626
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
2727
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
2828

29-
export const IHistoryMainService = createDecorator<IHistoryMainService>('historyMainService');
29+
export const IWorkspacesHistoryMainService = createDecorator<IWorkspacesHistoryMainService>('workspacesHistoryMainService');
3030

31-
export interface IHistoryMainService {
31+
export interface IWorkspacesHistoryMainService {
3232

3333
_serviceBrand: undefined;
3434

@@ -42,7 +42,7 @@ export interface IHistoryMainService {
4242
updateWindowsJumpList(): void;
4343
}
4444

45-
export class HistoryMainService implements IHistoryMainService {
45+
export class WorkspacesHistoryMainService implements IWorkspacesHistoryMainService {
4646

4747
private static readonly MAX_TOTAL_RECENT_ENTRIES = 100;
4848

@@ -108,7 +108,7 @@ export class HistoryMainService implements IHistoryMainService {
108108
// File
109109
else {
110110
const alreadyExistsInHistory = indexOfFile(files, curr.fileUri) >= 0;
111-
const shouldBeFiltered = curr.fileUri.scheme === Schemas.file && HistoryMainService.COMMON_FILES_FILTER.indexOf(basename(curr.fileUri)) >= 0;
111+
const shouldBeFiltered = curr.fileUri.scheme === Schemas.file && WorkspacesHistoryMainService.COMMON_FILES_FILTER.indexOf(basename(curr.fileUri)) >= 0;
112112

113113
if (!alreadyExistsInHistory && !shouldBeFiltered) {
114114
files.push(curr);
@@ -123,12 +123,12 @@ export class HistoryMainService implements IHistoryMainService {
123123

124124
this.addEntriesFromStorage(workspaces, files);
125125

126-
if (workspaces.length > HistoryMainService.MAX_TOTAL_RECENT_ENTRIES) {
127-
workspaces.length = HistoryMainService.MAX_TOTAL_RECENT_ENTRIES;
126+
if (workspaces.length > WorkspacesHistoryMainService.MAX_TOTAL_RECENT_ENTRIES) {
127+
workspaces.length = WorkspacesHistoryMainService.MAX_TOTAL_RECENT_ENTRIES;
128128
}
129129

130-
if (files.length > HistoryMainService.MAX_TOTAL_RECENT_ENTRIES) {
131-
files.length = HistoryMainService.MAX_TOTAL_RECENT_ENTRIES;
130+
if (files.length > WorkspacesHistoryMainService.MAX_TOTAL_RECENT_ENTRIES) {
131+
files.length = WorkspacesHistoryMainService.MAX_TOTAL_RECENT_ENTRIES;
132132
}
133133

134134
this.saveRecentlyOpened({ workspaces, files });
@@ -180,7 +180,7 @@ export class HistoryMainService implements IHistoryMainService {
180180
// Collect max-N recent workspaces that are known to exist
181181
const workspaceEntries: string[] = [];
182182
let entries = 0;
183-
for (let i = 0; i < mru.workspaces.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_WORKSPACES; i++) {
183+
for (let i = 0; i < mru.workspaces.length && entries < WorkspacesHistoryMainService.MAX_MACOS_DOCK_RECENT_WORKSPACES; i++) {
184184
const loc = location(mru.workspaces[i]);
185185
if (loc.scheme === Schemas.file) {
186186
const workspacePath = originalFSPath(loc);
@@ -193,12 +193,12 @@ export class HistoryMainService implements IHistoryMainService {
193193

194194
// Collect max-N recent files that are known to exist
195195
const fileEntries: string[] = [];
196-
for (let i = 0; i < mru.files.length && entries < HistoryMainService.MAX_MACOS_DOCK_RECENT_ENTRIES_TOTAL; i++) {
196+
for (let i = 0; i < mru.files.length && entries < WorkspacesHistoryMainService.MAX_MACOS_DOCK_RECENT_ENTRIES_TOTAL; i++) {
197197
const loc = location(mru.files[i]);
198198
if (loc.scheme === Schemas.file) {
199199
const filePath = originalFSPath(loc);
200200
if (
201-
HistoryMainService.COMMON_FILES_FILTER.indexOf(basename(loc)) !== -1 || // skip some well known file entries
201+
WorkspacesHistoryMainService.COMMON_FILES_FILTER.indexOf(basename(loc)) !== -1 || // skip some well known file entries
202202
workspaceEntries.indexOf(filePath) !== -1 // prefer a workspace entry over a file entry (e.g. for .code-workspace)
203203
) {
204204
continue;
@@ -285,15 +285,15 @@ export class HistoryMainService implements IHistoryMainService {
285285
}
286286

287287
private getRecentlyOpenedFromStorage(): IRecentlyOpened {
288-
const storedRecents = this.stateService.getItem<RecentlyOpenedStorageData>(HistoryMainService.recentlyOpenedStorageKey);
288+
const storedRecents = this.stateService.getItem<RecentlyOpenedStorageData>(WorkspacesHistoryMainService.recentlyOpenedStorageKey);
289289

290290
return restoreRecentlyOpened(storedRecents, this.logService);
291291
}
292292

293293
private saveRecentlyOpened(recent: IRecentlyOpened): void {
294294
const serialized = toStoreData(recent);
295295

296-
this.stateService.setItem(HistoryMainService.recentlyOpenedStorageKey, serialized);
296+
this.stateService.setItem(WorkspacesHistoryMainService.recentlyOpenedStorageKey, serialized);
297297
}
298298

299299
updateWindowsJumpList(): void {

src/vs/platform/history/test/electron-main/historyStorage.test.ts renamed to src/vs/platform/workspaces/test/electron-main/workspacesHistoryStorage.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import * as path from 'vs/base/common/path';
88

99
import { IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
1010
import { URI } from 'vs/base/common/uri';
11-
import { IRecentlyOpened, isRecentFolder, IRecentFolder, IRecentWorkspace } from 'vs/platform/history/common/history';
12-
import { toStoreData, restoreRecentlyOpened } from 'vs/platform/history/common/historyStorage';
11+
import { IRecentlyOpened, isRecentFolder, IRecentFolder, IRecentWorkspace } from 'vs/platform/workspaces/common/workspacesHistory';
12+
import { toStoreData, restoreRecentlyOpened } from 'vs/platform/workspaces/common/workspacesHistoryStorage';
1313
import { NullLogService } from 'vs/platform/log/common/log';
1414

1515
function toWorkspace(uri: URI): IWorkspaceIdentifier {
@@ -221,4 +221,4 @@ suite('History Storage', () => {
221221
});
222222

223223

224-
});
224+
});

src/vs/workbench/api/common/apiCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
1414
import { IOpenInWindowOptions, IWindowOpenable } from 'vs/platform/windows/common/windows';
1515
import { IWorkspacesHistoryService } from 'vs/workbench/services/workspace/common/workspacesHistoryService';
1616
import { IWorkspacesService, hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
17-
import { IRecent } from 'vs/platform/history/common/history';
17+
import { IRecent } from 'vs/platform/workspaces/common/workspacesHistory';
1818
import { Schemas } from 'vs/base/common/network';
1919

2020
// -----------------------------------------------------------------

0 commit comments

Comments
 (0)