Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
d4b310ea
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d4b310ea
编写于
7月 11, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix UI calls from shared process
fix #54070
上级
ed9171b2
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
68 addition
and
36 deletion
+68
-36
src/vs/base/parts/ipc/common/ipc.ts
src/vs/base/parts/ipc/common/ipc.ts
+14
-14
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
.../code/electron-browser/sharedProcess/sharedProcessMain.ts
+5
-12
src/vs/code/electron-main/app.ts
src/vs/code/electron-main/app.ts
+1
-1
src/vs/platform/driver/electron-main/driver.ts
src/vs/platform/driver/electron-main/driver.ts
+4
-4
src/vs/platform/windows/common/windows.ts
src/vs/platform/windows/common/windows.ts
+16
-3
src/vs/platform/windows/common/windowsIpc.ts
src/vs/platform/windows/common/windowsIpc.ts
+6
-0
src/vs/platform/windows/electron-main/windowsService.ts
src/vs/platform/windows/electron-main/windowsService.ts
+11
-1
src/vs/workbench/services/dialogs/electron-browser/dialogService.ts
...kbench/services/dialogs/electron-browser/dialogService.ts
+7
-1
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+4
-0
未找到文件。
src/vs/base/parts/ipc/common/ipc.ts
浏览文件 @
d4b310ea
...
...
@@ -94,8 +94,8 @@ export interface IChannelClient {
* channels (each from a separate client) to pick from.
*/
export
interface
IClientRouter
{
routeCall
(
command
:
string
,
arg
:
any
):
string
;
routeEvent
(
event
:
string
,
arg
:
any
):
string
;
routeCall
(
command
:
string
,
arg
:
any
):
TPromise
<
string
>
;
routeEvent
(
event
:
string
,
arg
:
any
):
TPromise
<
string
>
;
}
/**
...
...
@@ -433,24 +433,20 @@ export class IPCServer implements IChannelServer, IRoutingChannelClient, IDispos
getChannel
<
T
extends
IChannel
>
(
channelName
:
string
,
router
:
IClientRouter
):
T
{
const
call
=
(
command
:
string
,
arg
:
any
)
=>
{
const
id
=
router
.
routeCall
(
command
,
arg
);
const
channelPromise
=
router
.
routeCall
(
command
,
arg
)
.
then
(
id
=>
this
.
getClient
(
id
))
.
then
(
client
=>
client
.
getChannel
(
channelName
));
if
(
!
id
)
{
return
TPromise
.
wrapError
(
new
Error
(
'
Client id should be provided
'
));
}
return
getDelayedChannel
(
this
.
getClient
(
id
).
then
(
client
=>
client
.
getChannel
(
channelName
)))
return
getDelayedChannel
(
channelPromise
)
.
call
(
command
,
arg
);
};
const
listen
=
(
event
:
string
,
arg
:
any
)
=>
{
const
id
=
router
.
routeEvent
(
event
,
arg
);
if
(
!
id
)
{
return
TPromise
.
wrapError
(
new
Error
(
'
Client id should be provided
'
));
}
const
channelPromise
=
router
.
routeEvent
(
event
,
arg
)
.
then
(
id
=>
this
.
getClient
(
id
))
.
then
(
client
=>
client
.
getChannel
(
channelName
));
return
getDelayedChannel
(
this
.
getClient
(
id
).
then
(
client
=>
client
.
getChannel
(
channelName
))
)
return
getDelayedChannel
(
channelPromise
)
.
listen
(
event
,
arg
);
};
...
...
@@ -462,6 +458,10 @@ export class IPCServer implements IChannelServer, IRoutingChannelClient, IDispos
}
private
getClient
(
clientId
:
string
):
TPromise
<
IChannelClient
>
{
if
(
!
clientId
)
{
return
TPromise
.
wrapError
(
new
Error
(
'
Client id should be provided
'
));
}
const
client
=
this
.
channelClients
[
clientId
];
if
(
client
)
{
...
...
src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts
浏览文件 @
d4b310ea
...
...
@@ -67,7 +67,8 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
process
.
once
(
'
exit
'
,
()
=>
dispose
(
disposables
));
const
environmentService
=
new
EnvironmentService
(
initData
.
args
,
process
.
execPath
);
const
logLevelClient
=
new
LogLevelSetterChannelClient
(
server
.
getChannel
(
'
loglevel
'
,
{
routeCall
:
()
=>
'
main
'
,
routeEvent
:
()
=>
'
main
'
}));
const
mainRoute
=
()
=>
TPromise
.
as
(
'
main
'
);
const
logLevelClient
=
new
LogLevelSetterChannelClient
(
server
.
getChannel
(
'
loglevel
'
,
{
routeCall
:
mainRoute
,
routeEvent
:
mainRoute
}));
const
logService
=
new
FollowerLogService
(
logLevelClient
,
createSpdLogService
(
'
sharedprocess
'
,
initData
.
logLevel
,
environmentService
.
logsPath
));
disposables
.
push
(
logService
);
...
...
@@ -78,21 +79,13 @@ function main(server: Server, initData: ISharedProcessInitData, configuration: I
services
.
set
(
IConfigurationService
,
new
SyncDescriptor
(
ConfigurationService
));
services
.
set
(
IRequestService
,
new
SyncDescriptor
(
RequestService
));
const
windowsChannel
=
server
.
getChannel
(
'
windows
'
,
{
routeCall
:
()
=>
'
main
'
,
routeEvent
:
()
=>
'
main
'
});
const
windowsChannel
=
server
.
getChannel
(
'
windows
'
,
{
routeCall
:
mainRoute
,
routeEvent
:
mainRoute
});
const
windowsService
=
new
WindowsChannelClient
(
windowsChannel
);
services
.
set
(
IWindowsService
,
windowsService
);
const
activeWindowManager
=
new
ActiveWindowManager
(
windowsService
);
const
dialogChannel
=
server
.
getChannel
(
'
dialog
'
,
{
routeCall
:
()
=>
{
logService
.
info
(
'
Routing dialog call request to the client
'
,
activeWindowManager
.
activeClientId
);
return
activeWindowManager
.
activeClientId
;
},
routeEvent
:
()
=>
{
logService
.
info
(
'
Routing dialog listen request to the client
'
,
activeWindowManager
.
activeClientId
);
return
activeWindowManager
.
activeClientId
;
}
});
const
route
=
()
=>
activeWindowManager
.
getActiveClientId
();
const
dialogChannel
=
server
.
getChannel
(
'
dialog
'
,
{
routeCall
:
route
,
routeEvent
:
route
});
services
.
set
(
IDialogService
,
new
DialogChannelClient
(
dialogChannel
));
const
instantiationService
=
new
InstantiationService
(
services
);
...
...
src/vs/code/electron-main/app.ts
浏览文件 @
d4b310ea
...
...
@@ -426,7 +426,7 @@ export class CodeApplication {
// Create a URL handler which forwards to the last active window
const
activeWindowManager
=
new
ActiveWindowManager
(
windowsService
);
const
route
=
()
=>
activeWindowManager
.
activeClientId
;
const
route
=
()
=>
activeWindowManager
.
getActiveClientId
()
;
const
urlHandlerChannel
=
this
.
electronIpcServer
.
getChannel
(
'
urlHandler
'
,
{
routeCall
:
route
,
routeEvent
:
route
});
const
multiplexURLHandler
=
new
URLHandlerChannelClient
(
urlHandlerChannel
);
...
...
src/vs/platform/driver/electron-main/driver.ts
浏览文件 @
d4b310ea
...
...
@@ -27,12 +27,12 @@ class WindowRouter implements IClientRouter {
constructor
(
private
windowId
:
number
)
{
}
routeCall
():
string
{
return
`window:
${
this
.
windowId
}
`
;
routeCall
():
TPromise
<
string
>
{
return
TPromise
.
as
(
`window:
${
this
.
windowId
}
`
)
;
}
routeEvent
():
string
{
return
`window:
${
this
.
windowId
}
`
;
routeEvent
():
TPromise
<
string
>
{
return
TPromise
.
as
(
`window:
${
this
.
windowId
}
`
)
;
}
}
...
...
src/vs/platform/windows/common/windows.ts
浏览文件 @
d4b310ea
...
...
@@ -162,6 +162,7 @@ export interface IWindowsService {
getWindowCount
():
TPromise
<
number
>
;
log
(
severity
:
string
,
...
messages
:
string
[]):
TPromise
<
void
>
;
showItemInFolder
(
path
:
string
):
TPromise
<
void
>
;
getActiveWindowId
():
TPromise
<
number
|
undefined
>
;
// This needs to be handled from browser process to prevent
// foreground ordering issues on Windows
...
...
@@ -357,19 +358,31 @@ export interface IRunActionInWindowRequest {
export
class
ActiveWindowManager
implements
IDisposable
{
private
disposables
:
IDisposable
[]
=
[];
private
_activeWindowId
:
number
;
private
firstActiveWindowIdPromise
:
TPromise
<
any
>
|
null
;
private
_activeWindowId
:
number
|
undefined
;
constructor
(@
IWindowsService
windowsService
:
IWindowsService
)
{
const
onActiveWindowChange
=
latch
(
anyEvent
(
windowsService
.
onWindowOpen
,
windowsService
.
onWindowFocus
));
onActiveWindowChange
(
this
.
setActiveWindow
,
this
,
this
.
disposables
);
this
.
firstActiveWindowIdPromise
=
windowsService
.
getActiveWindowId
()
.
then
(
id
=>
(
typeof
this
.
_activeWindowId
===
'
undefined
'
)
&&
this
.
setActiveWindow
(
id
));
}
private
setActiveWindow
(
windowId
:
number
)
{
if
(
this
.
firstActiveWindowIdPromise
)
{
this
.
firstActiveWindowIdPromise
=
null
;
}
this
.
_activeWindowId
=
windowId
;
}
get
activeClientId
():
string
{
return
`window:
${
this
.
_activeWindowId
}
`
;
getActiveClientId
():
TPromise
<
string
>
{
if
(
this
.
firstActiveWindowIdPromise
)
{
return
this
.
firstActiveWindowIdPromise
;
}
return
TPromise
.
as
(
`window:
${
this
.
_activeWindowId
}
`
);
}
dispose
()
{
...
...
src/vs/platform/windows/common/windowsIpc.ts
浏览文件 @
d4b310ea
...
...
@@ -68,6 +68,7 @@ export interface IWindowsChannel extends IChannel {
call
(
command
:
'
toggleSharedProcess
'
):
TPromise
<
void
>
;
call
(
command
:
'
log
'
,
arg
:
[
string
,
string
[]]):
TPromise
<
void
>
;
call
(
command
:
'
showItemInFolder
'
,
arg
:
string
):
TPromise
<
void
>
;
call
(
command
:
'
getActiveWindowId
'
):
TPromise
<
number
>
;
call
(
command
:
'
openExternal
'
,
arg
:
string
):
TPromise
<
boolean
>
;
call
(
command
:
'
startCrashReporter
'
,
arg
:
CrashReporterStartOptions
):
TPromise
<
void
>
;
call
(
command
:
'
openAccessibilityOptions
'
):
TPromise
<
void
>
;
...
...
@@ -166,6 +167,7 @@ export class WindowsChannel implements IWindowsChannel {
case
'
quit
'
:
return
this
.
service
.
quit
();
case
'
log
'
:
return
this
.
service
.
log
(
arg
[
0
],
arg
[
1
]);
case
'
showItemInFolder
'
:
return
this
.
service
.
showItemInFolder
(
arg
);
case
'
getActiveWindowId
'
:
return
this
.
service
.
getActiveWindowId
();
case
'
openExternal
'
:
return
this
.
service
.
openExternal
(
arg
);
case
'
startCrashReporter
'
:
return
this
.
service
.
startCrashReporter
(
arg
);
case
'
openAccessibilityOptions
'
:
return
this
.
service
.
openAccessibilityOptions
();
...
...
@@ -364,6 +366,10 @@ export class WindowsChannelClient implements IWindowsService {
return
this
.
channel
.
call
(
'
showItemInFolder
'
,
path
);
}
getActiveWindowId
():
TPromise
<
number
|
undefined
>
{
return
this
.
channel
.
call
(
'
getActiveWindowId
'
);
}
openExternal
(
url
:
string
):
TPromise
<
boolean
>
{
return
this
.
channel
.
call
(
'
openExternal
'
,
url
);
}
...
...
src/vs/platform/windows/electron-main/windowsService.ts
浏览文件 @
d4b310ea
...
...
@@ -14,7 +14,7 @@ import product from 'vs/platform/node/product';
import
{
IWindowsService
,
OpenContext
,
INativeOpenDialogOptions
,
IEnterWorkspaceResult
,
IMessageBoxResult
,
IDevToolsOptions
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IEnvironmentService
,
ParsedArgs
}
from
'
vs/platform/environment/common/environment
'
;
import
{
shell
,
crashReporter
,
app
,
Menu
,
clipboard
,
BrowserWindow
}
from
'
electron
'
;
import
{
Event
,
fromNodeEventEmitter
,
mapEvent
,
filterEvent
,
anyEvent
}
from
'
vs/base/common/event
'
;
import
{
Event
,
fromNodeEventEmitter
,
mapEvent
,
filterEvent
,
anyEvent
,
latch
}
from
'
vs/base/common/event
'
;
import
{
IURLService
,
IURLHandler
}
from
'
vs/platform/url/common/url
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/electron-main/lifecycleMain
'
;
import
{
IWindowsMainService
,
ISharedProcess
}
from
'
vs/platform/windows/electron-main/windows
'
;
...
...
@@ -32,6 +32,8 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
private
disposables
:
IDisposable
[]
=
[];
private
_activeWindowId
:
number
|
undefined
;
readonly
onWindowOpen
:
Event
<
number
>
=
filterEvent
(
fromNodeEventEmitter
(
app
,
'
browser-window-created
'
,
(
_
,
w
:
Electron
.
BrowserWindow
)
=>
w
.
id
),
id
=>
!!
this
.
windowsMainService
.
getWindowById
(
id
));
readonly
onWindowFocus
:
Event
<
number
>
=
anyEvent
(
mapEvent
(
filterEvent
(
mapEvent
(
this
.
windowsMainService
.
onWindowsCountChanged
,
()
=>
this
.
windowsMainService
.
getLastActiveWindow
()),
w
=>
!!
w
),
w
=>
w
.
id
),
...
...
@@ -54,6 +56,10 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
@
ILogService
private
logService
:
ILogService
)
{
urlService
.
registerHandler
(
this
);
// remember last active window id
latch
(
anyEvent
(
this
.
onWindowOpen
,
this
.
onWindowFocus
))
(
id
=>
this
.
_activeWindowId
=
id
,
null
,
this
.
disposables
);
}
pickFileFolderAndOpen
(
options
:
INativeOpenDialogOptions
):
TPromise
<
void
>
{
...
...
@@ -435,6 +441,10 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable
return
TPromise
.
as
(
null
);
}
getActiveWindowId
():
TPromise
<
number
|
undefined
>
{
return
TPromise
.
as
(
this
.
_activeWindowId
);
}
openExternal
(
url
:
string
):
TPromise
<
boolean
>
{
this
.
logService
.
trace
(
'
windowsService#openExternal
'
);
return
TPromise
.
as
(
shell
.
openExternal
(
url
));
...
...
src/vs/workbench/services/dialogs/electron-browser/dialogService.ts
浏览文件 @
d4b310ea
...
...
@@ -13,6 +13,7 @@ import { isLinux, isWindows } from 'vs/base/common/platform';
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
mnemonicButtonLabel
}
from
'
vs/base/common/labels
'
;
import
{
IDialogService
,
IConfirmation
,
IConfirmationResult
,
IDialogOptions
}
from
'
vs/platform/dialogs/common/dialogs
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
interface
IMassagedMessageBoxOptions
{
...
...
@@ -34,10 +35,13 @@ export class DialogService implements IDialogService {
_serviceBrand
:
any
;
constructor
(
@
IWindowService
private
windowService
:
IWindowService
@
IWindowService
private
windowService
:
IWindowService
,
@
ILogService
private
logService
:
ILogService
)
{
}
confirm
(
confirmation
:
IConfirmation
):
TPromise
<
IConfirmationResult
>
{
this
.
logService
.
trace
(
'
DialogService#confirm
'
,
confirmation
.
message
);
const
{
options
,
buttonIndexMap
}
=
this
.
massageMessageBoxOptions
(
this
.
getConfirmOptions
(
confirmation
));
return
this
.
windowService
.
showMessageBox
(
options
).
then
(
result
=>
{
...
...
@@ -86,6 +90,8 @@ export class DialogService implements IDialogService {
}
show
(
severity
:
Severity
,
message
:
string
,
buttons
:
string
[],
dialogOptions
?:
IDialogOptions
):
TPromise
<
number
>
{
this
.
logService
.
trace
(
'
DialogService#show
'
,
message
);
const
{
options
,
buttonIndexMap
}
=
this
.
massageMessageBoxOptions
({
message
,
buttons
,
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
d4b310ea
...
...
@@ -1295,6 +1295,10 @@ export class TestWindowsService implements IWindowsService {
return
TPromise
.
as
(
void
0
);
}
getActiveWindowId
():
TPromise
<
number
|
undefined
>
{
return
TPromise
.
as
(
undefined
);
}
// This needs to be handled from browser process to prevent
// foreground ordering issues on Windows
openExternal
(
url
:
string
):
TPromise
<
boolean
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录