提交 dc925370 编写于 作者: M Martin Aeschlimann

add IOpenConfiguration.noRecentEntry

上级 b19c6902
......@@ -574,16 +574,17 @@ export class CodeApplication extends Disposable {
const hasCliArgs = hasArgs(args._);
const hasFolderURIs = hasArgs(args['folder-uri']);
const hasFileURIs = hasArgs(args['file-uri']);
const noRecentEntry = args['skip-add-to-recently-opened'] === true;
if (args['new-window'] && !hasCliArgs && !hasFolderURIs && !hasFileURIs) {
return this.windowsMainService.open({ context, cli: args, forceNewWindow: true, forceEmpty: true, initialStartup: true }); // new window if "-n" was used without paths
return this.windowsMainService.open({ context, cli: args, forceNewWindow: true, forceEmpty: true, noRecentEntry, initialStartup: true }); // new window if "-n" was used without paths
}
if (macOpenFiles && macOpenFiles.length && !hasCliArgs && !hasFolderURIs && !hasFileURIs) {
return this.windowsMainService.open({ context: OpenContext.DOCK, cli: args, urisToOpen: macOpenFiles.map(file => ({ uri: URI.file(file) })), initialStartup: true }); // mac: open-file event received on startup
return this.windowsMainService.open({ context: OpenContext.DOCK, cli: args, urisToOpen: macOpenFiles.map(file => ({ uri: URI.file(file) })), noRecentEntry, initialStartup: true }); // mac: open-file event received on startup
}
return this.windowsMainService.open({ context, cli: args, forceNewWindow: args['new-window'] || (!hasCliArgs && args['unity-launch']), diffMode: args.diff, initialStartup: true }); // default: read paths from cli
return this.windowsMainService.open({ context, cli: args, forceNewWindow: args['new-window'] || (!hasCliArgs && args['unity-launch']), diffMode: args.diff, noRecentEntry, initialStartup: true }); // default: read paths from cli
}
private afterWindowOpen(accessor: ServicesAccessor): void {
......
......@@ -489,7 +489,7 @@ 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.diffMode && !this.environmentService.skipAddToRecentlyOpened) {
if (!usedWindows.some(w => w.isExtensionDevelopmentHost) && !openConfig.diffMode && !openConfig.noRecentEntry) {
const recents: IRecent[] = [];
for (let pathToOpen of pathsToOpen) {
if (pathToOpen.workspace) {
......@@ -1216,7 +1216,7 @@ export class WindowsManager implements IWindowsMainService {
}
// Open it
this.open({ context: openConfig.context, cli: openConfig.cli, forceNewWindow: true, forceEmpty: !cliArgs.length && !folderUris.length && !fileUris.length, userEnv: openConfig.userEnv });
this.open({ context: openConfig.context, cli: openConfig.cli, forceNewWindow: true, forceEmpty: !cliArgs.length && !folderUris.length && !fileUris.length, userEnv: openConfig.userEnv, noRecentEntry: true });
}
private openInBrowserWindow(options: IOpenBrowserWindowOptions): ICodeWindow {
......
......@@ -215,7 +215,8 @@ export class LaunchService implements ILaunchService {
preferNewWindow: !args['reuse-window'] && !args.wait,
forceReuseWindow: args['reuse-window'],
diffMode: args.diff,
addMode: args.add
addMode: args.add,
noRecentEntry: !!args['skip-add-to-recently-opened']
});
}
......
......@@ -182,6 +182,7 @@ export interface IOpenSettings {
forceOpenWorkspaceAsFile?: boolean;
diffMode?: boolean;
addMode?: boolean;
noRecentEntry?: boolean;
args?: ParsedArgs;
}
......
......@@ -134,6 +134,7 @@ export interface IOpenConfiguration {
addMode?: boolean;
readonly forceOpenWorkspaceAsFile?: boolean;
readonly initialStartup?: boolean;
readonly noRecentEntry?: boolean;
}
export interface ISharedProcess {
......
......@@ -273,7 +273,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
});
}
async openWindow(windowId: number, urisToOpen: IURIToOpen[], options?: IOpenSettings): Promise<void> {
async openWindow(windowId: number, urisToOpen: IURIToOpen[], options: IOpenSettings = {}): Promise<void> {
this.logService.trace('windowsService#openWindow');
if (!urisToOpen || !urisToOpen.length) {
return undefined;
......@@ -283,12 +283,13 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
context: OpenContext.API,
contextWindowId: windowId,
urisToOpen: urisToOpen,
cli: options && options.args ? { ...this.environmentService.args, ...options.args } : this.environmentService.args,
forceNewWindow: options && options.forceNewWindow,
forceReuseWindow: options && options.forceReuseWindow,
forceOpenWorkspaceAsFile: options && options.forceOpenWorkspaceAsFile,
diffMode: options && options.diffMode,
addMode: options && options.addMode
cli: options.args ? { ...this.environmentService.args, ...options.args } : this.environmentService.args,
forceNewWindow: options.forceNewWindow,
forceReuseWindow: options.forceReuseWindow,
forceOpenWorkspaceAsFile: options.forceOpenWorkspaceAsFile,
diffMode: options.diffMode,
addMode: options.addMode,
noRecentEntry: options.noRecentEntry
});
}
......
......@@ -48,10 +48,7 @@ export class OpenFolderAPICommand {
if (!uri) {
return executor.executeCommand('_files.pickFolderAndOpen', arg.forceNewWindow);
}
const options: IOpenSettings = { forceNewWindow: arg.forceNewWindow };
if (arg.noRecentEntry) {
options.args = { _: [], 'skip-add-to-recently-opened': true };
}
const options: IOpenSettings = { forceNewWindow: arg.forceNewWindow, noRecentEntry: arg.noRecentEntry };
uri = URI.revive(uri);
return executor.executeCommand('_files.windowOpen', [{ uri, label: arg.recentEntryLabel }], options);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册