From 712e4fe789a84b12bf846cb7d2759c99df7d7955 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 3 Nov 2016 21:17:17 +0100 Subject: [PATCH] ipc: remove vscode:showItemInFolder #10587 --- src/vs/code/electron-main/windows.ts | 6 ------ src/vs/platform/windows/common/windows.ts | 1 + src/vs/platform/windows/common/windowsIpc.ts | 6 ++++++ .../platform/windows/electron-main/windowsService.ts | 6 ++++++ src/vs/workbench/electron-browser/window.ts | 4 ---- .../extensions/electron-browser/extensionsActions.ts | 10 ++++------ .../files/electron-browser/electronFileActions.ts | 9 ++++----- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 8402d188501..2fe45b20603 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -255,12 +255,6 @@ export class WindowsManager implements IWindowsMainService, IWindowEventService } }); - ipc.on('vscode:showItemInFolder', (event, path: string) => { - this.logService.log('IPC#vscode-showItemInFolder'); - - shell.showItemInFolder(path); - }); - ipc.on('vscode:openExternal', (event, url: string) => { this.logService.log('IPC#vscode-openExternal'); diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index 857d30bb902..200f7303251 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -38,6 +38,7 @@ export interface IWindowsService { log(severity: string, ...messages: string[]): TPromise; // TODO@joao: what? closeExtensionHostWindow(extensionDevelopmentPath: string): TPromise; + showItemInFolder(path: string): TPromise; } export const IWindowService = createDecorator('windowService'); diff --git a/src/vs/platform/windows/common/windowsIpc.ts b/src/vs/platform/windows/common/windowsIpc.ts index 802b15d3f7a..3f73ca7f9f2 100644 --- a/src/vs/platform/windows/common/windowsIpc.ts +++ b/src/vs/platform/windows/common/windowsIpc.ts @@ -28,6 +28,7 @@ export interface IWindowsChannel extends IChannel { call(command: 'getWindows'): TPromise<{ id: number; path: string; title: string; }[]>; call(command: 'log', args: [string, string[]]): TPromise; call(command: 'closeExtensionHostWindow', args: string): TPromise; + call(command: 'showItemInFolder', args: string): TPromise; call(command: string, arg?: any): TPromise; } @@ -56,6 +57,7 @@ export class WindowsChannel implements IWindowsChannel { case 'getWindows': return this.service.getWindows(); case 'log': return this.service.log(arg[0], arg[1]); case 'closeExtensionHostWindow': return this.service.closeExtensionHostWindow(arg); + case 'showItemInFolder': return this.service.showItemInFolder(arg); } } } @@ -141,4 +143,8 @@ export class WindowsChannelClient implements IWindowsService { closeExtensionHostWindow(extensionDevelopmentPath: string): TPromise { return this.channel.call('closeExtensionHostWindow', extensionDevelopmentPath); } + + showItemInFolder(path: string): TPromise { + return this.channel.call('showItemInFolder', path); + } } \ No newline at end of file diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index 6d81800ffcc..4094cef4839 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -8,6 +8,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; import { IWindowsService } from 'vs/platform/windows/common/windows'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; +import { shell } from 'electron'; // TODO@Joao: remove this dependency, move all implementation to this class import { IWindowsMainService } from 'vs/code/electron-main/windows'; @@ -176,4 +177,9 @@ export class WindowsService implements IWindowsService { return TPromise.as(null); } + + showItemInFolder(path: string): TPromise { + shell.showItemInFolder(path); + return TPromise.as(null); + } } \ No newline at end of file diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 2c38587aaa6..65bf61daf8c 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -158,10 +158,6 @@ export class ElectronWindow { return this.windowService.focusWindow(); } - public showItemInFolder(path: string): void { - ipc.send('vscode:showItemInFolder', path); // handled from browser process to prevent foreground ordering issues on Windows - } - public openExternal(url: string): void { ipc.send('vscode:openExternal', url); // handled from browser process to prevent foreground ordering issues on Windows } diff --git a/src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts b/src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts index d763f2c2a37..9ec4af10195 100644 --- a/src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts +++ b/src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts @@ -14,7 +14,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { IMessageService } from 'vs/platform/message/common/message'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { remote } from 'electron'; -import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService'; +import { IWindowsService } from 'vs/platform/windows/common/windows'; const dialog = remote.dialog; @@ -26,17 +26,15 @@ export class OpenExtensionsFolderAction extends Action { constructor( id: string, label: string, - @IWindowIPCService private windowService: IWindowIPCService, + @IWindowsService private windowsService: IWindowsService, @IEnvironmentService private environmentService: IEnvironmentService ) { super(id, label, null, true); } - run(): TPromise { + run(): TPromise { const extensionsHome = this.environmentService.extensionsPath; - this.windowService.getWindow().showItemInFolder(paths.normalize(extensionsHome, true)); - - return TPromise.as(true); + return this.windowsService.showItemInFolder(paths.normalize(extensionsHome, true)); } protected isEnabled(): boolean { diff --git a/src/vs/workbench/parts/files/electron-browser/electronFileActions.ts b/src/vs/workbench/parts/files/electron-browser/electronFileActions.ts index 74b715160b2..444981345a3 100644 --- a/src/vs/workbench/parts/files/electron-browser/electronFileActions.ts +++ b/src/vs/workbench/parts/files/electron-browser/electronFileActions.ts @@ -17,7 +17,6 @@ import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/edi import { asFileEditorInput } from 'vs/workbench/common/editor'; import { IMessageService } from 'vs/platform/message/common/message'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; -import { IWindowIPCService } from 'vs/workbench/services/window/electron-browser/windowService'; import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows'; import { clipboard } from 'electron'; @@ -26,7 +25,7 @@ export class RevealInOSAction extends Action { constructor( resource: uri, - @IWindowIPCService private windowService: IWindowIPCService + @IWindowsService private windowsService: IWindowsService ) { super('workbench.action.files.revealInWindows', platform.isWindows ? nls.localize('revealInWindows', "Reveal in Explorer") : (platform.isMacintosh ? nls.localize('revealInMac', "Reveal in Finder") : nls.localize('openContainer', "Open Containing Folder"))); @@ -36,7 +35,7 @@ export class RevealInOSAction extends Action { } public run(): TPromise { - this.windowService.getWindow().showItemInFolder(paths.normalize(this.resource.fsPath, true)); + this.windowsService.showItemInFolder(paths.normalize(this.resource.fsPath, true)); return TPromise.as(true); } @@ -51,7 +50,7 @@ export class GlobalRevealInOSAction extends Action { id: string, label: string, @IWorkbenchEditorService private editorService: IWorkbenchEditorService, - @IWindowIPCService private windowService: IWindowIPCService, + @IWindowsService private windowsService: IWindowsService, @IMessageService private messageService: IMessageService ) { super(id, label); @@ -60,7 +59,7 @@ export class GlobalRevealInOSAction extends Action { public run(): TPromise { const fileInput = asFileEditorInput(this.editorService.getActiveEditorInput(), true); if (fileInput) { - this.windowService.getWindow().showItemInFolder(paths.normalize(fileInput.getResource().fsPath, true)); + this.windowsService.showItemInFolder(paths.normalize(fileInput.getResource().fsPath, true)); } else { this.messageService.show(severity.Info, nls.localize('openFileToReveal', "Open a file first to reveal")); } -- GitLab