提交 33189b32 编写于 作者: B Benjamin Pasero

workspaces service 💄

上级 4a59a415
......@@ -491,7 +491,7 @@ export class Menubar {
}).length > 0;
if (!success) {
this.workspacesHistoryMainService.removeFromRecentlyOpened([revivedUri]);
this.workspacesHistoryMainService.removeRecentlyOpened([revivedUri]);
}
}
}, false));
......
......@@ -1190,7 +1190,7 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
}
} catch (error) {
const fileUri = URI.file(candidate);
this.workspacesHistoryMainService.removeFromRecentlyOpened([fileUri]); // since file does not seem to exist anymore, remove from recent
this.workspacesHistoryMainService.removeRecentlyOpened([fileUri]); // since file does not seem to exist anymore, remove from recent
// assume this is a file that does not yet exist
if (options?.ignoreFileNotFound) {
......
......@@ -40,7 +40,7 @@ export interface IWorkspacesService {
// History
readonly onRecentlyOpenedChange: CommonEvent<void>;
addRecentlyOpened(recents: IRecent[]): Promise<void>;
removeFromRecentlyOpened(workspaces: URI[]): Promise<void>;
removeRecentlyOpened(workspaces: URI[]): Promise<void>;
clearRecentlyOpened(): Promise<void>;
getRecentlyOpened(): Promise<IRecentlyOpened>;
}
......
......@@ -35,7 +35,7 @@ export interface IWorkspacesHistoryMainService {
addRecentlyOpened(recents: IRecent[]): void;
getRecentlyOpened(currentWorkspace?: IWorkspaceIdentifier, currentFolder?: ISingleFolderWorkspaceIdentifier, currentFiles?: IPath[]): IRecentlyOpened;
removeFromRecentlyOpened(paths: URI[]): void;
removeRecentlyOpened(paths: URI[]): void;
clearRecentlyOpened(): void;
updateWindowsJumpList(): void;
......@@ -148,7 +148,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
}
}
removeFromRecentlyOpened(toRemove: URI[]): void {
removeRecentlyOpened(toRemove: URI[]): void {
const keep = (recent: IRecent) => {
const uri = location(recent);
for (const r of toRemove) {
......@@ -344,7 +344,7 @@ export class WorkspacesHistoryMainService extends Disposable implements IWorkspa
}
}
}
this.removeFromRecentlyOpened(toRemove);
this.removeRecentlyOpened(toRemove);
// Add entries
jumpList.push({
......
......@@ -63,8 +63,8 @@ export class WorkspacesService implements AddFirstParameterToFunctions<IWorkspac
return this.workspacesHistoryMainService.addRecentlyOpened(recents);
}
async removeFromRecentlyOpened(windowId: number, paths: URI[]): Promise<void> {
return this.workspacesHistoryMainService.removeFromRecentlyOpened(paths);
async removeRecentlyOpened(windowId: number, paths: URI[]): Promise<void> {
return this.workspacesHistoryMainService.removeRecentlyOpened(paths);
}
async clearRecentlyOpened(windowId: number): Promise<void> {
......
......@@ -158,7 +158,7 @@ CommandsRegistry.registerCommand(OpenWithAPICommand.ID, adjustHandler(OpenWithAP
CommandsRegistry.registerCommand('_workbench.removeFromRecentlyOpened', function (accessor: ServicesAccessor, uri: URI) {
const workspacesService = accessor.get(IWorkspacesService);
return workspacesService.removeFromRecentlyOpened([uri]);
return workspacesService.removeRecentlyOpened([uri]);
});
export class RemoveFromRecentlyOpenedAPICommand {
......
......@@ -129,7 +129,7 @@ abstract class BaseOpenRecentAction extends Action {
onKeyMods: mods => keyMods = mods,
quickNavigate: this.isQuickNavigate() ? { keybindings: this.keybindingService.lookupKeybindings(this.id) } : undefined,
onDidTriggerItemButton: async context => {
await this.workspacesService.removeFromRecentlyOpened([context.item.resource]);
await this.workspacesService.removeRecentlyOpened([context.item.resource]);
context.removeItem();
}
});
......
......@@ -273,7 +273,7 @@ export class HistoryService extends Disposable implements IHistoryService {
const input = arg1 as IResourceInput;
this.workspacesService.removeFromRecentlyOpened([input.resource]);
this.workspacesService.removeRecentlyOpened([input.resource]);
}
clear(): void {
......
......@@ -35,6 +35,8 @@ export class BrowserWorkspacesService extends Disposable implements IWorkspacesS
) {
super();
// Opening a workspace should push it as most
// recently used to the workspaces history
this.addWorkspaceToRecentlyOpened();
this.registerListeners();
......@@ -76,13 +78,13 @@ export class BrowserWorkspacesService extends Disposable implements IWorkspacesS
recents.forEach(recent => {
if (isRecentFile(recent)) {
this.doRemoveFromRecentlyOpened(recentlyOpened, [recent.fileUri]);
this.doRemoveRecentlyOpened(recentlyOpened, [recent.fileUri]);
recentlyOpened.files.unshift(recent);
} else if (isRecentFolder(recent)) {
this.doRemoveFromRecentlyOpened(recentlyOpened, [recent.folderUri]);
this.doRemoveRecentlyOpened(recentlyOpened, [recent.folderUri]);
recentlyOpened.workspaces.unshift(recent);
} else {
this.doRemoveFromRecentlyOpened(recentlyOpened, [recent.workspace.configPath]);
this.doRemoveRecentlyOpened(recentlyOpened, [recent.workspace.configPath]);
recentlyOpened.workspaces.unshift(recent);
}
});
......@@ -90,15 +92,15 @@ export class BrowserWorkspacesService extends Disposable implements IWorkspacesS
return this.saveRecentlyOpened(recentlyOpened);
}
async removeFromRecentlyOpened(paths: URI[]): Promise<void> {
async removeRecentlyOpened(paths: URI[]): Promise<void> {
const recentlyOpened = await this.getRecentlyOpened();
this.doRemoveFromRecentlyOpened(recentlyOpened, paths);
this.doRemoveRecentlyOpened(recentlyOpened, paths);
return this.saveRecentlyOpened(recentlyOpened);
}
private doRemoveFromRecentlyOpened(recentlyOpened: IRecentlyOpened, paths: URI[]): void {
private doRemoveRecentlyOpened(recentlyOpened: IRecentlyOpened, paths: URI[]): void {
recentlyOpened.files = recentlyOpened.files.filter(file => {
return !paths.some(path => path.toString() === file.fileUri.toString());
});
......
......@@ -131,11 +131,14 @@ export class NativeWorkspaceEditingService extends AbstractWorkspaceEditingServi
try {
await this.saveWorkspaceAs(workspaceIdentifier, newWorkspacePath);
// Make sure to add the new workspace to the history to find it again
const newWorkspaceIdentifier = await this.workspacesService.getWorkspaceIdentifier(newWorkspacePath);
this.workspacesService.addRecentlyOpened([{
label: this.labelService.getWorkspaceLabel(newWorkspaceIdentifier, { verbose: true }),
workspace: newWorkspaceIdentifier
}]);
const label = this.labelService.getWorkspaceLabel(newWorkspaceIdentifier, { verbose: true });
this.workspacesService.addRecentlyOpened([{ label, workspace: newWorkspaceIdentifier }]);
// Delete the untitled one
this.workspacesService.deleteUntitledWorkspace(workspaceIdentifier);
} catch (error) {
// ignore
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册