debt - introduce and use workspaces history service

This commit is contained in:
Benjamin Pasero
2019-09-26 15:33:57 +02:00
parent 969e23ed64
commit a036c0f273
24 changed files with 181 additions and 260 deletions

View File

@@ -11,7 +11,8 @@ import { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import { EditorViewColumn } from 'vs/workbench/api/common/shared/editor';
import { EditorGroupLayout } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IWindowService, IOpenInWindowOptions, IWindowOpenable } from 'vs/platform/windows/common/windows';
import { IOpenInWindowOptions, IWindowOpenable } from 'vs/platform/windows/common/windows';
import { IWorkspacesHistoryService } from 'vs/workbench/services/workspace/common/workspacesHistoryService';
import { IWorkspacesService, hasWorkspaceFileExtension } from 'vs/platform/workspaces/common/workspaces';
import { IRecent } from 'vs/platform/history/common/history';
import { Schemas } from 'vs/base/common/network';
@@ -132,8 +133,8 @@ export class OpenAPICommand {
CommandsRegistry.registerCommand(OpenAPICommand.ID, adjustHandler(OpenAPICommand.execute));
CommandsRegistry.registerCommand('_workbench.removeFromRecentlyOpened', function (accessor: ServicesAccessor, uri: URI) {
const windowService = accessor.get(IWindowService);
return windowService.removeFromRecentlyOpened([uri]);
const workspacesHistoryService = accessor.get(IWorkspacesHistoryService);
return workspacesHistoryService.removeFromRecentlyOpened([uri]);
});
export class RemoveFromRecentlyOpenedAPICommand {
@@ -163,7 +164,7 @@ interface RecentEntry {
}
CommandsRegistry.registerCommand('_workbench.addToRecentlyOpened', async function (accessor: ServicesAccessor, recentEntry: RecentEntry) {
const windowService = accessor.get(IWindowService);
const workspacesHistoryService = accessor.get(IWorkspacesHistoryService);
const workspacesService = accessor.get(IWorkspacesService);
let recent: IRecent | undefined = undefined;
const uri = recentEntry.uri;
@@ -176,12 +177,12 @@ CommandsRegistry.registerCommand('_workbench.addToRecentlyOpened', async functio
} else {
recent = { fileUri: uri, label };
}
return windowService.addRecentlyOpened([recent]);
return workspacesHistoryService.addRecentlyOpened([recent]);
});
CommandsRegistry.registerCommand('_workbench.getRecentlyOpened', async function (accessor: ServicesAccessor) {
const windowService = accessor.get(IWindowService);
return windowService.getRecentlyOpened();
const workspacesHistoryService = accessor.get(IWorkspacesHistoryService);
return workspacesHistoryService.getRecentlyOpened();
});
export class SetEditorLayoutAPICommand {