提交 2a18cb8e 编写于 作者: B Benjamin Pasero

recently opened: some renames

上级 0373d29d
......@@ -385,7 +385,7 @@ export class CodeApplication {
// Jump List
this.historyService.updateWindowsJumpList();
this.historyService.onRecentPathsChange(() => this.historyService.updateWindowsJumpList());
this.historyService.onRecentlyOpenedChange(() => this.historyService.updateWindowsJumpList());
// Start shared process here
this.sharedProcess.spawn();
......
......@@ -100,7 +100,7 @@ export class CodeMenu {
// Listen to some events from window service
this.windowsService.onPathsOpen(paths => this.updateMenu());
this.historyService.onRecentPathsChange(paths => this.updateMenu());
this.historyService.onRecentlyOpenedChange(paths => this.updateMenu());
this.windowsService.onWindowClose(_ => this.onClose(this.windowsService.getWindowCount()));
// Listen to extension viewlets
......@@ -428,7 +428,7 @@ export class CodeMenu {
private setOpenRecentMenu(openRecentMenu: Electron.Menu): void {
openRecentMenu.append(this.createMenuItem(nls.localize({ key: 'miReopenClosedEditor', comment: ['&& denotes a mnemonic'] }, "&&Reopen Closed Editor"), 'workbench.action.reopenClosedEditor'));
const { folders, files } = this.historyService.getRecentPathsList();
const { folders, files } = this.historyService.getRecentlyOpened();
// Folders
if (folders.length > 0) {
......@@ -462,7 +462,7 @@ export class CodeMenu {
const openInNewWindow = this.isOptionClick(event);
const success = this.windowsService.open({ context: OpenContext.MENU, cli: this.environmentService.args, pathsToOpen: [path], forceNewWindow: openInNewWindow }).length > 0;
if (!success) {
this.historyService.removeFromRecentPathsList(path);
this.historyService.removeFromRecentlyOpened(path);
}
}
}, false));
......
......@@ -343,16 +343,16 @@ export class WindowsManager implements IWindowsMainService {
// Remember in recent document list (unless this opens for extension development)
// Also do not add paths when files are opened for diffing, only if opened individually
if (!usedWindows.some(w => w.isExtensionDevelopmentHost) && !openConfig.cli.diff) {
const recentPaths: { path: string; isFile?: boolean; }[] = [];
const recentlyOpened: { path: string; isFile?: boolean; }[] = [];
windowsToOpen.forEach(win => {
if (win.filePath || win.folderPath) {
recentPaths.push({ path: win.filePath || win.folderPath, isFile: !!win.filePath });
recentlyOpened.push({ path: win.filePath || win.folderPath, isFile: !!win.filePath });
}
});
if (recentPaths.length) {
this.historyService.addToRecentPathsList(recentPaths);
if (recentlyOpened.length) {
this.historyService.addToRecentlyOpened(recentlyOpened);
}
}
......@@ -777,7 +777,7 @@ export class WindowsManager implements IWindowsMainService {
};
}
} catch (error) {
this.historyService.removeFromRecentPathsList(candidate); // since file does not seem to exist anymore, remove from recent
this.historyService.removeFromRecentlyOpened(candidate); // since file does not seem to exist anymore, remove from recent
if (ignoreFileNotFound) {
return { filePath: candidate, createFilePath: true }; // assume this is a file that does not yet exist
......
......@@ -20,7 +20,7 @@ import { isWindows, isMacintosh, isLinux } from 'vs/base/common/platform';
export const IHistoryMainService = createDecorator<IHistoryMainService>('historyMainService');
export interface IRecentPathsList {
export interface IRecentlyOpened {
folders: string[];
files: string[];
}
......@@ -29,15 +29,14 @@ export interface IHistoryMainService {
_serviceBrand: any;
// events
onRecentPathsChange: CommonEvent<void>;
onRecentlyOpenedChange: CommonEvent<void>;
// methods
addToRecentPathsList(paths: { path: string; isFile?: boolean; }[]): void;
getRecentPathsList(folderPath?: string, filesToOpen?: IPath[]): IRecentPathsList;
removeFromRecentPathsList(path: string): void;
removeFromRecentPathsList(paths: string[]): void;
clearRecentPathsList(): void;
addToRecentlyOpened(paths: { path: string; isFile?: boolean; }[]): void;
getRecentlyOpened(folderPath?: string, filesToOpen?: IPath[]): IRecentlyOpened;
removeFromRecentlyOpened(path: string): void;
removeFromRecentlyOpened(paths: string[]): void;
clearRecentlyOpened(): void;
updateWindowsJumpList(): void;
}
......@@ -45,12 +44,12 @@ export class HistoryMainService implements IHistoryMainService {
private static MAX_TOTAL_RECENT_ENTRIES = 100;
private static recentPathsListStorageKey = 'openedPathsList';
private static recentlyOpenedStorageKey = 'openedPathsList';
_serviceBrand: any;
private _onRecentPathsChange = new Emitter<void>();
onRecentPathsChange: CommonEvent<void> = this._onRecentPathsChange.event;
private _onRecentlyOpenedChange = new Emitter<void>();
onRecentlyOpenedChange: CommonEvent<void> = this._onRecentlyOpenedChange.event;
constructor(
@IStorageService private storageService: IStorageService,
......@@ -58,12 +57,12 @@ export class HistoryMainService implements IHistoryMainService {
) {
}
public addToRecentPathsList(paths: { path: string; isFile?: boolean; }[]): void {
public addToRecentlyOpened(paths: { path: string; isFile?: boolean; }[]): void {
if (!paths || !paths.length) {
return;
}
const mru = this.getRecentPathsList();
const mru = this.getRecentlyOpened();
paths.forEach(p => {
const { path, isFile } = p;
......@@ -85,13 +84,13 @@ export class HistoryMainService implements IHistoryMainService {
}
});
this.storageService.setItem(HistoryMainService.recentPathsListStorageKey, mru);
this._onRecentPathsChange.fire();
this.storageService.setItem(HistoryMainService.recentlyOpenedStorageKey, mru);
this._onRecentlyOpenedChange.fire();
}
public removeFromRecentPathsList(path: string): void;
public removeFromRecentPathsList(paths: string[]): void;
public removeFromRecentPathsList(arg1: any): void {
public removeFromRecentlyOpened(path: string): void;
public removeFromRecentlyOpened(paths: string[]): void;
public removeFromRecentlyOpened(arg1: any): void {
let paths: string[];
if (Array.isArray(arg1)) {
paths = arg1;
......@@ -99,7 +98,7 @@ export class HistoryMainService implements IHistoryMainService {
paths = [arg1];
}
const mru = this.getRecentPathsList();
const mru = this.getRecentlyOpened();
let update = false;
paths.forEach(path => {
......@@ -117,25 +116,25 @@ export class HistoryMainService implements IHistoryMainService {
});
if (update) {
this.storageService.setItem(HistoryMainService.recentPathsListStorageKey, mru);
this._onRecentPathsChange.fire();
this.storageService.setItem(HistoryMainService.recentlyOpenedStorageKey, mru);
this._onRecentlyOpenedChange.fire();
}
}
public clearRecentPathsList(): void {
this.storageService.setItem(HistoryMainService.recentPathsListStorageKey, { folders: [], files: [] });
public clearRecentlyOpened(): void {
this.storageService.setItem(HistoryMainService.recentlyOpenedStorageKey, { folders: [], files: [] });
app.clearRecentDocuments();
// Event
this._onRecentPathsChange.fire();
this._onRecentlyOpenedChange.fire();
}
public getRecentPathsList(folderPath?: string, filesToOpen?: IPath[]): IRecentPathsList {
public getRecentlyOpened(folderPath?: string, filesToOpen?: IPath[]): IRecentlyOpened {
let files: string[];
let folders: string[];
// Get from storage
const storedRecents = this.storageService.getItem<IRecentPathsList>(HistoryMainService.recentPathsListStorageKey);
const storedRecents = this.storageService.getItem<IRecentlyOpened>(HistoryMainService.recentlyOpenedStorageKey);
if (storedRecents) {
files = storedRecents.files || [];
folders = storedRecents.folders || [];
......@@ -185,19 +184,19 @@ export class HistoryMainService implements IHistoryMainService {
});
// Recent Folders
if (this.getRecentPathsList().folders.length > 0) {
if (this.getRecentlyOpened().folders.length > 0) {
// The user might have meanwhile removed items from the jump list and we have to respect that
// so we need to update our list of recent paths with the choice of the user to not add them again
// Also: Windows will not show our custom category at all if there is any entry which was removed
// by the user! See https://github.com/Microsoft/vscode/issues/15052
this.removeFromRecentPathsList(app.getJumpListSettings().removedItems.map(r => trim(r.args, '"')));
this.removeFromRecentlyOpened(app.getJumpListSettings().removedItems.map(r => trim(r.args, '"')));
// Add entries
jumpList.push({
type: 'custom',
name: nls.localize('recentFolders', "Recent Folders"),
items: this.getRecentPathsList().folders.slice(0, 7 /* limit number of entries here */).map(folder => {
items: this.getRecentlyOpened().folders.slice(0, 7 /* limit number of entries here */).map(folder => {
return <Electron.JumpListItem>{
type: 'task',
title: path.basename(folder) || folder, // use the base name to show shorter entries in the list
......
......@@ -32,10 +32,10 @@ export interface IWindowsService {
closeFolder(windowId: number): TPromise<void>;
toggleFullScreen(windowId: number): TPromise<void>;
setRepresentedFilename(windowId: number, fileName: string): TPromise<void>;
addToRecentlyOpen(paths: { path: string, isFile?: boolean }[]): TPromise<void>;
removeFromRecentlyOpen(paths: string[]): TPromise<void>;
clearRecentPathsList(): TPromise<void>;
getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }>;
addToRecentlyOpened(paths: { path: string, isFile?: boolean }[]): TPromise<void>;
removeFromRecentlyOpened(paths: string[]): TPromise<void>;
clearRecentlyOpened(): TPromise<void>;
getRecentlyOpened(windowId: number): TPromise<{ files: string[]; folders: string[]; }>;
focusWindow(windowId: number): TPromise<void>;
closeWindow(windowId: number): TPromise<void>;
isFocused(windowId: number): TPromise<boolean>;
......@@ -87,7 +87,7 @@ export interface IWindowService {
closeFolder(): TPromise<void>;
toggleFullScreen(): TPromise<void>;
setRepresentedFilename(fileName: string): TPromise<void>;
getRecentlyOpen(): TPromise<{ files: string[]; folders: string[]; }>;
getRecentlyOpened(): TPromise<{ files: string[]; folders: string[]; }>;
focusWindow(): TPromise<void>;
closeWindow(): TPromise<void>;
isFocused(): TPromise<boolean>;
......
......@@ -23,10 +23,10 @@ export interface IWindowsChannel extends IChannel {
call(command: 'closeFolder', arg: number): TPromise<void>;
call(command: 'toggleFullScreen', arg: number): TPromise<void>;
call(command: 'setRepresentedFilename', arg: [number, string]): TPromise<void>;
call(command: 'addToRecentlyOpen', arg: { path: string, isFile?: boolean }[]): TPromise<void>;
call(command: 'removeFromRecentlyOpen', arg: string[]): TPromise<void>;
call(command: 'clearRecentPathsList'): TPromise<void>;
call(command: 'getRecentlyOpen', arg: number): TPromise<{ files: string[]; folders: string[]; }>;
call(command: 'addToRecentlyOpened', arg: { path: string, isFile?: boolean }[]): TPromise<void>;
call(command: 'removeFromRecentlyOpened', arg: string[]): TPromise<void>;
call(command: 'clearRecentlyOpened'): TPromise<void>;
call(command: 'getRecentlyOpened', arg: number): TPromise<{ files: string[]; folders: string[]; }>;
call(command: 'focusWindow', arg: number): TPromise<void>;
call(command: 'closeWindow', arg: number): TPromise<void>;
call(command: 'isFocused', arg: number): TPromise<boolean>;
......@@ -76,10 +76,10 @@ export class WindowsChannel implements IWindowsChannel {
case 'closeFolder': return this.service.closeFolder(arg);
case 'toggleFullScreen': return this.service.toggleFullScreen(arg);
case 'setRepresentedFilename': return this.service.setRepresentedFilename(arg[0], arg[1]);
case 'addToRecentlyOpen': return this.service.addToRecentlyOpen(arg);
case 'removeFromRecentlyOpen': return this.service.removeFromRecentlyOpen(arg);
case 'clearRecentPathsList': return this.service.clearRecentPathsList();
case 'getRecentlyOpen': return this.service.getRecentlyOpen(arg);
case 'addToRecentlyOpened': return this.service.addToRecentlyOpened(arg);
case 'removeFromRecentlyOpened': return this.service.removeFromRecentlyOpened(arg);
case 'clearRecentlyOpened': return this.service.clearRecentlyOpened();
case 'getRecentlyOpened': return this.service.getRecentlyOpened(arg);
case 'focusWindow': return this.service.focusWindow(arg);
case 'closeWindow': return this.service.closeWindow(arg);
case 'isFocused': return this.service.isFocused(arg);
......@@ -159,20 +159,20 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('setRepresentedFilename', [windowId, fileName]);
}
addToRecentlyOpen(paths: { path: string, isFile?: boolean }[]): TPromise<void> {
return this.channel.call('addToRecentlyOpen', paths);
addToRecentlyOpened(paths: { path: string, isFile?: boolean }[]): TPromise<void> {
return this.channel.call('addToRecentlyOpened', paths);
}
removeFromRecentlyOpen(paths: string[]): TPromise<void> {
return this.channel.call('removeFromRecentlyOpen', paths);
removeFromRecentlyOpened(paths: string[]): TPromise<void> {
return this.channel.call('removeFromRecentlyOpened', paths);
}
clearRecentPathsList(): TPromise<void> {
return this.channel.call('clearRecentPathsList');
clearRecentlyOpened(): TPromise<void> {
return this.channel.call('clearRecentlyOpened');
}
getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
return this.channel.call('getRecentlyOpen', windowId);
getRecentlyOpened(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
return this.channel.call('getRecentlyOpened', windowId);
}
focusWindow(windowId: number): TPromise<void> {
......
......@@ -67,8 +67,8 @@ export class WindowService implements IWindowService {
return this.windowsService.setRepresentedFilename(this.windowId, fileName);
}
getRecentlyOpen(): TPromise<{ files: string[]; folders: string[]; }> {
return this.windowsService.getRecentlyOpen(this.windowId);
getRecentlyOpened(): TPromise<{ files: string[]; folders: string[]; }> {
return this.windowsService.getRecentlyOpened(this.windowId);
}
focusWindow(): TPromise<void> {
......
......@@ -139,28 +139,28 @@ export class WindowsService implements IWindowsService, IDisposable {
return TPromise.as(null);
}
addToRecentlyOpen(paths: { path: string, isFile?: boolean }[]): TPromise<void> {
this.historyService.addToRecentPathsList(paths);
addToRecentlyOpened(paths: { path: string, isFile?: boolean }[]): TPromise<void> {
this.historyService.addToRecentlyOpened(paths);
return TPromise.as(null);
}
removeFromRecentlyOpen(paths: string[]): TPromise<void> {
this.historyService.removeFromRecentPathsList(paths);
removeFromRecentlyOpened(paths: string[]): TPromise<void> {
this.historyService.removeFromRecentlyOpened(paths);
return TPromise.as(null);
}
clearRecentPathsList(): TPromise<void> {
this.historyService.clearRecentPathsList();
clearRecentlyOpened(): TPromise<void> {
this.historyService.clearRecentlyOpened();
return TPromise.as(null);
}
getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
getRecentlyOpened(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
const codeWindow = this.windowsMainService.getWindowById(windowId);
if (codeWindow) {
const { files, folders } = this.historyService.getRecentPathsList(codeWindow.config.folderPath, codeWindow.config.filesToOpen);
const { files, folders } = this.historyService.getRecentlyOpened(codeWindow.config.folderPath, codeWindow.config.filesToOpen);
return TPromise.as({ files, folders });
}
......
......@@ -1150,7 +1150,7 @@ export class ClearRecentFilesAction extends Action {
}
public run(): TPromise<any> {
this.windowsService.clearRecentPathsList();
this.windowsService.clearRecentlyOpened();
return TPromise.as(false);
}
......
......@@ -1118,7 +1118,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
// Add external ones to recently open list
const externalResources = droppedResources.filter(d => d.isExternal).map(d => d.resource);
if (externalResources.length) {
$this.windowsService.addToRecentlyOpen(externalResources.map(resource => {
$this.windowsService.addToRecentlyOpened(externalResources.map(resource => {
return {
path: resource.fsPath,
isFile: true
......
......@@ -691,7 +691,7 @@ export class TabsTitleControl extends TitleControl {
// Add external ones to recently open list
const externalResources = resources.filter(d => d.isExternal).map(d => d.resource);
if (externalResources.length) {
this.windowsService.addToRecentlyOpen(externalResources.map(resource => {
this.windowsService.addToRecentlyOpened(externalResources.map(resource => {
return {
path: resource.fsPath,
isFile: true
......
......@@ -663,7 +663,7 @@ export abstract class BaseOpenRecentAction extends Action {
protected abstract isQuickNavigate(): boolean;
public run(): TPromise<void> {
return this.windowService.getRecentlyOpen()
return this.windowService.getRecentlyOpened()
.then(({ files, folders }) => this.openRecent(files, folders));
}
......
......@@ -188,7 +188,7 @@ class WelcomePage {
}
private create() {
const recentlyOpened = this.windowService.getRecentlyOpen();
const recentlyOpened = this.windowService.getRecentlyOpened();
const installedExtensions = this.instantiationService.invokeFunction(getInstalledExtensions);
const uri = URI.parse(require.toUrl('./vs_code_welcome_page'))
.with({
......
......@@ -395,7 +395,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this.removeFromHistory(arg1);
this.removeFromStack(arg1);
this.removeFromRecentlyClosedFiles(arg1);
this.removeFromRecentlyOpen(arg1);
this.removeFromRecentlyOpened(arg1);
}
private removeExcludedFromHistory(): void {
......@@ -568,14 +568,14 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this.recentlyClosedFiles = this.recentlyClosedFiles.filter(e => !this.matchesFile(e.resource, arg1));
}
private removeFromRecentlyOpen(arg1: IEditorInput | IResourceInput | FileChangesEvent): void {
private removeFromRecentlyOpened(arg1: IEditorInput | IResourceInput | FileChangesEvent): void {
if (arg1 instanceof EditorInput || arg1 instanceof FileChangesEvent) {
return; // for now do not delete from file events since recently open are likely out of workspace files for which there are no delete events
}
const input = arg1 as IResourceInput;
this.windowService.removeFromRecentlyOpen([input.resource.fsPath]);
this.windowService.removeFromRecentlyOpened([input.resource.fsPath]);
}
private isFileOpened(resource: URI, group: IEditorGroup): boolean {
......
......@@ -889,7 +889,7 @@ export class TestWindowService implements IWindowService {
return TPromise.as(void 0);
}
getRecentlyOpen(): TPromise<{ files: string[]; folders: string[]; }> {
getRecentlyOpened(): TPromise<{ files: string[]; folders: string[]; }> {
return TPromise.as(void 0);
}
......@@ -1017,19 +1017,19 @@ export class TestWindowsService implements IWindowsService {
return TPromise.as(void 0);
}
addToRecentlyOpen(paths: { path: string, isFile?: boolean }[]): TPromise<void> {
addToRecentlyOpened(paths: { path: string, isFile?: boolean }[]): TPromise<void> {
return TPromise.as(void 0);
}
removeFromRecentlyOpen(paths: string[]): TPromise<void> {
removeFromRecentlyOpened(paths: string[]): TPromise<void> {
return TPromise.as(void 0);
}
clearRecentPathsList(): TPromise<void> {
clearRecentlyOpened(): TPromise<void> {
return TPromise.as(void 0);
}
getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
getRecentlyOpened(windowId: number): TPromise<{ files: string[]; folders: string[]; }> {
return TPromise.as(void 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册