Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b24be3a8
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,发现更多精彩内容 >>
提交
b24be3a8
编写于
5月 02, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cleanup imports
上级
fda1e698
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
155 addition
and
159 deletion
+155
-159
src/vs/code/electron-main/auto-updater.linux.ts
src/vs/code/electron-main/auto-updater.linux.ts
+2
-2
src/vs/code/electron-main/auto-updater.win32.ts
src/vs/code/electron-main/auto-updater.win32.ts
+11
-11
src/vs/code/electron-main/env.ts
src/vs/code/electron-main/env.ts
+15
-15
src/vs/code/electron-main/lifecycle.ts
src/vs/code/electron-main/lifecycle.ts
+9
-10
src/vs/code/electron-main/main.ts
src/vs/code/electron-main/main.ts
+24
-24
src/vs/code/electron-main/menus.ts
src/vs/code/electron-main/menus.ts
+9
-10
src/vs/code/electron-main/settings.ts
src/vs/code/electron-main/settings.ts
+1
-1
src/vs/code/electron-main/sharedProcess.ts
src/vs/code/electron-main/sharedProcess.ts
+1
-1
src/vs/code/electron-main/storage.ts
src/vs/code/electron-main/storage.ts
+7
-8
src/vs/code/electron-main/update-manager.ts
src/vs/code/electron-main/update-manager.ts
+6
-6
src/vs/code/electron-main/window.ts
src/vs/code/electron-main/window.ts
+7
-7
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+63
-64
未找到文件。
src/vs/code/electron-main/auto-updater.linux.ts
浏览文件 @
b24be3a8
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
events
=
require
(
'
events
'
)
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
isString
}
from
'
vs/base/common/types
'
;
import
{
Promise
}
from
'
vs/base/common/winjs.base
'
;
import
{
json
}
from
'
vs/base/node/request
'
;
...
...
@@ -20,7 +20,7 @@ export interface IUpdate {
version
?:
string
;
}
export
class
LinuxAutoUpdaterImpl
extends
events
.
EventEmitter
{
export
class
LinuxAutoUpdaterImpl
extends
EventEmitter
{
private
url
:
string
;
private
currentRequest
:
Promise
;
...
...
src/vs/code/electron-main/auto-updater.win32.ts
浏览文件 @
b24be3a8
...
...
@@ -5,11 +5,11 @@
'
use strict
'
;
import
events
=
require
(
'
events
'
)
;
import
path
=
require
(
'
path
'
)
;
import
os
=
require
(
'
os
'
)
;
import
cp
=
require
(
'
child_process
'
)
;
import
pfs
=
require
(
'
vs/base/node/pfs
'
)
;
import
*
as
path
from
'
path
'
;
import
*
as
pfs
from
'
vs/base/node/pfs
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
tmpdir
}
from
'
os
'
;
import
{
spawn
}
from
'
child_process
'
;
import
{
mkdirp
}
from
'
vs/base/node/extfs
'
;
import
{
isString
}
from
'
vs/base/common/types
'
;
import
{
Promise
,
TPromise
}
from
'
vs/base/common/winjs.base
'
;
...
...
@@ -26,7 +26,7 @@ export interface IUpdate {
version
?:
string
;
}
export
class
Win32AutoUpdaterImpl
extends
events
.
EventEmitter
{
export
class
Win32AutoUpdaterImpl
extends
EventEmitter
{
private
url
:
string
;
private
currentRequest
:
Promise
;
...
...
@@ -42,16 +42,16 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter {
this
.
currentRequest
=
null
;
}
public
get
cachePath
():
TPromise
<
string
>
{
let
result
=
path
.
join
(
os
.
tmpdir
(),
'
vscode-update
'
);
get
cachePath
():
TPromise
<
string
>
{
let
result
=
path
.
join
(
tmpdir
(),
'
vscode-update
'
);
return
new
TPromise
<
string
>
((
c
,
e
)
=>
mkdirp
(
result
,
null
,
err
=>
err
?
e
(
err
)
:
c
(
result
)));
}
public
setFeedURL
(
url
:
string
):
void
{
setFeedURL
(
url
:
string
):
void
{
this
.
url
=
url
;
}
public
checkForUpdates
():
void
{
checkForUpdates
():
void
{
if
(
!
this
.
url
)
{
throw
new
Error
(
'
No feed url set.
'
);
}
...
...
@@ -123,7 +123,7 @@ export class Win32AutoUpdaterImpl extends events.EventEmitter {
return
;
}
cp
.
spawn
(
updatePackagePath
,
[
'
/silent
'
,
'
/mergetasks=runcode,!desktopicon,!quicklaunchicon
'
],
{
spawn
(
updatePackagePath
,
[
'
/silent
'
,
'
/mergetasks=runcode,!desktopicon,!quicklaunchicon
'
],
{
detached
:
true
,
stdio
:
[
'
ignore
'
,
'
ignore
'
,
'
ignore
'
]
});
...
...
src/vs/code/electron-main/env.ts
浏览文件 @
b24be3a8
...
...
@@ -5,19 +5,19 @@
'
use strict
'
;
import
crypto
=
require
(
'
crypto
'
)
;
import
fs
=
require
(
'
fs
'
)
;
import
path
=
require
(
'
path
'
)
;
import
os
=
require
(
'
os
'
)
;
import
{
app
}
from
'
electron
'
;
import
arrays
=
require
(
'
vs/base/common/arrays
'
)
;
import
strings
=
require
(
'
vs/base/common/strings
'
)
;
import
paths
=
require
(
'
vs/base/common/paths
'
)
;
import
platform
=
require
(
'
vs/base/common/platform
'
)
;
import
uri
from
'
vs/base/common/uri
'
;
import
types
=
require
(
'
vs/base/common/types
'
)
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
product
,
{
IProductConfiguration
}
from
'
vs/code/node/product
'
;
import
*
as
crypto
from
'
crypto
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
path
from
'
path
'
;
import
{
tmpdir
}
from
'
os
'
;
import
{
app
}
from
'
electron
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
product
,
{
IProductConfiguration
}
from
'
vs/code/node/product
'
;
import
{
parseArgs
}
from
'
vs/code/node/argv
'
;
export
interface
IProcessEnvironment
{
...
...
@@ -132,7 +132,7 @@ export class EnvService implements IEnvironmentService {
get
sharedIPCHandle
():
string
{
return
this
.
_sharedIPCHandle
;
}
constructor
()
{
this
.
_appRoot
=
path
.
dirname
(
uri
.
parse
(
require
.
toUrl
(
''
)).
fsPath
);
this
.
_appRoot
=
path
.
dirname
(
URI
.
parse
(
require
.
toUrl
(
''
)).
fsPath
);
this
.
_currentWorkingDirectory
=
process
.
env
[
'
VSCODE_CWD
'
]
||
process
.
cwd
();
this
.
_version
=
app
.
getVersion
();
this
.
_appHome
=
app
.
getPath
(
'
userData
'
);
...
...
@@ -239,7 +239,7 @@ export class EnvService implements IEnvironmentService {
return
'
\\\\
.
\\
pipe
\\
'
+
handleName
;
}
return
path
.
join
(
os
.
tmpdir
(),
handleName
);
return
path
.
join
(
tmpdir
(),
handleName
);
}
private
static
getUniqueUserId
():
string
{
...
...
src/vs/code/electron-main/lifecycle.ts
浏览文件 @
b24be3a8
...
...
@@ -5,14 +5,13 @@
'
use strict
'
;
import
events
=
require
(
'
events
'
);
import
{
ipcMain
as
ipc
,
app
}
from
'
electron
'
;
import
{
TPromise
,
TValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
{
ReadyState
,
VSCodeWindow
}
from
'
vs/code/electron-main/window
'
;
import
env
=
require
(
'
vs/code/electron-main/env
'
);
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILogService
}
from
'
./log
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
ipcMain
as
ipc
,
app
}
from
'
electron
'
;
import
{
TPromise
,
TValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
{
ReadyState
,
VSCodeWindow
}
from
'
vs/code/electron-main/window
'
;
import
{
IEnvironmentService
}
from
'
vs/code/electron-main/env
'
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILogService
}
from
'
./log
'
;
const
EventTypes
=
{
BEFORE_QUIT
:
'
before-quit
'
...
...
@@ -33,7 +32,7 @@ export class LifecycleService implements ILifecycleService {
serviceId
=
ILifecycleService
;
private
eventEmitter
=
new
events
.
EventEmitter
();
private
eventEmitter
=
new
EventEmitter
();
private
windowToCloseRequest
:
{
[
windowId
:
string
]:
boolean
};
private
quitRequested
:
boolean
;
private
pendingQuitPromise
:
TPromise
<
boolean
>
;
...
...
@@ -41,7 +40,7 @@ export class LifecycleService implements ILifecycleService {
private
oneTimeListenerTokenGenerator
:
number
;
constructor
(
@
env
.
IEnvironmentService
private
envService
:
env
.
IEnvironmentService
,
@
IEnvironmentService
private
envService
:
IEnvironmentService
,
@
ILogService
private
logService
:
ILogService
)
{
this
.
windowToCloseRequest
=
Object
.
create
(
null
);
...
...
src/vs/code/electron-main/main.ts
浏览文件 @
b24be3a8
...
...
@@ -5,31 +5,31 @@
'
use strict
'
;
import
{
app
,
ipcMain
as
ipc
}
from
'
electron
'
;
import
fs
=
require
(
'
fs
'
)
;
import
nls
=
require
(
'
vs/nls
'
)
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
platform
=
require
(
'
vs/base/common/platform
'
)
;
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
fs
from
'
fs
'
;
import
{
app
,
ipcMain
as
ipc
}
from
'
electron
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
IProcessEnvironment
,
IEnvironmentService
,
EnvService
}
from
'
vs/code/electron-main/env
'
;
import
windows
=
require
(
'
vs/code/electron-main/windows
'
)
;
import
{
IWindowsService
,
WindowsManager
}
from
'
vs/code/electron-main/windows
'
;
import
{
ILifecycleService
,
LifecycleService
}
from
'
vs/code/electron-main/lifecycle
'
;
import
{
VSCodeMenu
}
from
'
vs/code/electron-main/menus
'
;
import
{
ISettingsService
,
SettingsManager
}
from
'
vs/code/electron-main/settings
'
;
import
{
IUpdateService
,
UpdateManager
}
from
'
vs/code/electron-main/update-manager
'
;
import
{
Server
,
serve
,
connect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
getUnixUserEnvironment
,
IEnv
}
from
'
vs/base/node/env
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
AskpassChannel
}
from
'
vs/workbench/parts/git/common/gitIpc
'
;
import
{
GitAskpassService
}
from
'
vs/workbench/parts/git/electron-main/askpassService
'
;
import
{
spawnSharedProcess
}
from
'
vs/code/electron-main/sharedProcess
'
;
import
{
Mutex
}
from
'
windows-mutex
'
;
import
{
LaunchService
,
ILaunchChannel
,
LaunchChannel
,
LaunchChannelClient
}
from
'
./launch
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ILogService
,
MainLogService
}
from
'
./log
'
;
import
{
IStorageService
,
StorageService
}
from
'
./storage
'
;
import
{
ISettingsService
,
SettingsManager
}
from
'
vs/code/electron-main/settings
'
;
import
{
IUpdateService
,
UpdateManager
}
from
'
vs/code/electron-main/update-manager
'
;
import
{
Server
,
serve
,
connect
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
getUnixUserEnvironment
,
IEnv
}
from
'
vs/base/node/env
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
AskpassChannel
}
from
'
vs/workbench/parts/git/common/gitIpc
'
;
import
{
GitAskpassService
}
from
'
vs/workbench/parts/git/electron-main/askpassService
'
;
import
{
spawnSharedProcess
}
from
'
vs/code/electron-main/sharedProcess
'
;
import
{
Mutex
}
from
'
windows-mutex
'
;
import
{
LaunchService
,
ILaunchChannel
,
LaunchChannel
,
LaunchChannelClient
}
from
'
./launch
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
InstantiationService
}
from
'
vs/platform/instantiation/common/instantiationService
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ILogService
,
MainLogService
}
from
'
./log
'
;
import
{
IStorageService
,
StorageService
}
from
'
./storage
'
;
function
quit
(
accessor
:
ServicesAccessor
,
error
?:
Error
);
function
quit
(
accessor
:
ServicesAccessor
,
message
?:
string
);
...
...
@@ -55,7 +55,7 @@ function main(accessor: ServicesAccessor, ipcServer: Server, userEnv: IProcessEn
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
logService
=
accessor
.
get
(
ILogService
);
const
envService
=
accessor
.
get
(
IEnvironmentService
);
const
windowManager
=
accessor
.
get
(
windows
.
IWindowsService
);
const
windowManager
=
accessor
.
get
(
IWindowsService
);
const
lifecycleService
=
accessor
.
get
(
ILifecycleService
);
const
updateManager
=
accessor
.
get
(
IUpdateService
);
const
settingsManager
=
accessor
.
get
(
ISettingsService
);
...
...
@@ -258,7 +258,7 @@ const services = new ServiceCollection();
services
.
set
(
IEnvironmentService
,
new
SyncDescriptor
(
EnvService
));
services
.
set
(
ILogService
,
new
SyncDescriptor
(
MainLogService
));
services
.
set
(
windows
.
IWindowsService
,
new
SyncDescriptor
(
windows
.
WindowsManager
));
services
.
set
(
IWindowsService
,
new
SyncDescriptor
(
WindowsManager
));
services
.
set
(
ILifecycleService
,
new
SyncDescriptor
(
LifecycleService
));
services
.
set
(
IStorageService
,
new
SyncDescriptor
(
StorageService
));
services
.
set
(
IUpdateService
,
new
SyncDescriptor
(
UpdateManager
));
...
...
src/vs/code/electron-main/menus.ts
浏览文件 @
b24be3a8
...
...
@@ -5,17 +5,16 @@
'
use strict
'
;
import
{
ipcMain
as
ipc
,
app
,
shell
,
dialog
,
Menu
,
MenuItem
}
from
'
electron
'
;
import
nls
=
require
(
'
vs/nls
'
)
;
import
platform
=
require
(
'
vs/base/common/platform
'
)
;
import
arrays
=
require
(
'
vs/base/common/arrays
'
)
;
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
*
as
env
from
'
vs/code/electron-main/env
'
;
import
{
ipcMain
as
ipc
,
app
,
shell
,
dialog
,
Menu
,
MenuItem
}
from
'
electron
'
;
import
{
IWindowsService
,
WindowsManager
,
IOpenedPathsList
}
from
'
vs/code/electron-main/windows
'
;
import
window
=
require
(
'
vs/code/electron-main/window
'
);
import
env
=
require
(
'
vs/code/electron-main/env
'
);
import
{
IPath
,
VSCodeWindow
}
from
'
vs/code/electron-main/window
'
;
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
import
{
IUpdateService
,
State
as
UpdateState
}
from
'
vs/code/electron-main/update-manager
'
;
import
{
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
Keybinding
}
from
'
vs/base/common/keyCodes
'
;
interface
IResolvedKeybinding
{
id
:
string
;
...
...
@@ -105,7 +104,7 @@ export class VSCodeMenu {
this
.
updateManager
.
on
(
'
change
'
,
()
=>
this
.
updateMenu
());
}
private
resolveKeybindings
(
win
:
window
.
VSCodeWindow
):
void
{
private
resolveKeybindings
(
win
:
VSCodeWindow
):
void
{
if
(
this
.
keybindingsResolved
)
{
return
;
// only resolve once
}
...
...
@@ -134,7 +133,7 @@ export class VSCodeMenu {
}
}
private
onOpen
(
path
:
window
.
IPath
):
void
{
private
onOpen
(
path
:
IPath
):
void
{
this
.
addToOpenedPathsList
(
path
.
filePath
||
path
.
workspacePath
,
!!
path
.
filePath
);
this
.
updateMenu
();
}
...
...
src/vs/code/electron-main/settings.ts
浏览文件 @
b24be3a8
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
app
}
from
'
electron
'
;
import
{
app
}
from
'
electron
'
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
UserSettings
,
ISettings
}
from
'
vs/workbench/node/userSettings
'
;
import
{
IEnvironmentService
}
from
'
vs/code/electron-main/env
'
;
...
...
src/vs/code/electron-main/sharedProcess.ts
浏览文件 @
b24be3a8
...
...
@@ -11,7 +11,7 @@ import { IEnvironment } from 'vs/platform/workspace/common/workspace';
import
{
IEnvironmentService
}
from
'
vs/code/electron-main/env
'
;
import
{
ISettingsService
}
from
'
vs/code/electron-main/settings
'
;
import
{
IUpdateService
}
from
'
vs/code/electron-main/update-manager
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
const
boostrapPath
=
URI
.
parse
(
require
.
toUrl
(
'
bootstrap
'
)).
fsPath
;
...
...
src/vs/code/electron-main/storage.ts
浏览文件 @
b24be3a8
...
...
@@ -3,14 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
path
=
require
(
'
path
'
)
;
import
fs
=
require
(
'
fs
'
)
;
import
events
=
require
(
'
events
'
)
;
import
env
=
require
(
'
vs/code/electron-main/env
'
)
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
*
as
path
from
'
path
'
;
import
*
as
fs
from
'
fs
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
IEnvironmentService
}
from
'
vs/code/electron-main/env
'
;
import
{
ServiceIdentifier
,
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
const
EventTypes
=
{
STORE
:
'
store
'
...
...
@@ -32,9 +31,9 @@ export class StorageService implements IStorageService {
private
dbPath
:
string
;
private
database
:
any
=
null
;
private
eventEmitter
=
new
events
.
EventEmitter
();
private
eventEmitter
=
new
EventEmitter
();
constructor
(@
env
.
IEnvironmentService
private
envService
:
env
.
IEnvironmentService
)
{
constructor
(@
IEnvironmentService
private
envService
:
IEnvironmentService
)
{
this
.
dbPath
=
path
.
join
(
envService
.
appHome
,
'
storage.json
'
);
}
...
...
src/vs/code/electron-main/update-manager.ts
浏览文件 @
b24be3a8
...
...
@@ -5,11 +5,11 @@
'
use strict
'
;
import
fs
=
require
(
'
fs
'
)
;
import
path
=
require
(
'
path
'
)
;
import
events
=
require
(
'
events
'
)
;
import
electron
=
require
(
'
electron
'
)
;
import
platform
=
require
(
'
vs/base/common/platform
'
)
;
import
*
as
fs
from
'
fs
'
;
import
*
as
path
from
'
path
'
;
import
*
as
electron
from
'
electron
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
IEnvironmentService
,
getPlatformIdentifier
}
from
'
vs/code/electron-main/env
'
;
import
{
ISettingsService
}
from
'
vs/code/electron-main/settings
'
;
import
{
Win32AutoUpdaterImpl
}
from
'
vs/code/electron-main/auto-updater.win32
'
;
...
...
@@ -56,7 +56,7 @@ export interface IUpdateService {
on
(
event
:
string
,
listener
:
Function
):
this
;
}
export
class
UpdateManager
extends
events
.
EventEmitter
implements
IUpdateService
{
export
class
UpdateManager
extends
EventEmitter
implements
IUpdateService
{
serviceId
=
IUpdateService
;
...
...
src/vs/code/electron-main/window.ts
浏览文件 @
b24be3a8
...
...
@@ -5,13 +5,13 @@
'
use strict
'
;
import
path
=
require
(
'
path
'
);
import
{
shell
,
screen
,
BrowserWindow
}
from
'
electron
'
;
import
{
TPromise
,
TValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
platform
=
require
(
'
vs/base/common/platform
'
);
import
objects
=
require
(
'
vs/base/common/objects
'
);
import
*
as
path
from
'
path
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
import
{
shell
,
screen
,
BrowserWindow
}
from
'
electron
'
;
import
{
TPromise
,
TValueCallback
}
from
'
vs/base/common/winjs.base
'
;
import
{
ICommandLineArguments
,
IEnvironmentService
,
IProcessEnvironment
}
from
'
vs/code/electron-main/env
'
;
import
storage
=
require
(
'
vs/code/electron-main/storage
'
);
import
{
ILogService
}
from
'
./log
'
;
export
interface
IWindowState
{
...
...
@@ -158,7 +158,7 @@ export class VSCodeWindow {
config
:
IWindowCreationOptions
,
@
ILogService
private
logService
:
ILogService
,
@
IEnvironmentService
private
envService
:
IEnvironmentService
,
@
storage
.
IStorageService
private
storageService
:
storage
.
IStorageService
@
IStorageService
private
storageService
:
IStorageService
)
{
this
.
_lastFocusTime
=
-
1
;
this
.
_readyState
=
ReadyState
.
NONE
;
...
...
src/vs/code/electron-main/windows.ts
浏览文件 @
b24be3a8
...
...
@@ -3,26 +3,25 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
events
=
require
(
'
events
'
);
import
path
=
require
(
'
path
'
);
import
fs
=
require
(
'
fs
'
);
import
{
ipcMain
as
ipc
,
app
,
screen
,
crashReporter
,
BrowserWindow
,
dialog
}
from
'
electron
'
;
import
platform
=
require
(
'
vs/base/common/platform
'
);
import
*
as
path
from
'
path
'
;
import
*
as
fs
from
'
fs
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
EventEmitter
}
from
'
events
'
;
import
{
IStorageService
}
from
'
vs/code/electron-main/storage
'
;
import
{
IPath
,
VSCodeWindow
,
ReadyState
,
IWindowConfiguration
,
IWindowState
as
ISingleWindowState
,
defaultWindowState
}
from
'
vs/code/electron-main/window
'
;
import
{
ipcMain
as
ipc
,
app
,
screen
,
crashReporter
,
BrowserWindow
,
dialog
}
from
'
electron
'
;
import
{
ICommandLineArguments
,
IProcessEnvironment
,
IEnvironmentService
,
IParsedPath
,
parseLineAndColumnAware
}
from
'
vs/code/electron-main/env
'
;
import
window
=
require
(
'
vs/code/electron-main/window
'
);
import
{
ILifecycleService
}
from
'
vs/code/electron-main/lifecycle
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
arrays
=
require
(
'
vs/base/common/arrays
'
);
import
objects
=
require
(
'
vs/base/common/objects
'
);
import
storage
=
require
(
'
vs/code/electron-main/storage
'
);
import
{
ISettingsService
}
from
'
vs/code/electron-main/settings
'
;
import
{
IUpdateService
,
IUpdate
}
from
'
vs/code/electron-main/update-manager
'
;
import
{
ISettingsService
}
from
'
vs/code/electron-main/settings
'
;
import
{
IUpdateService
,
IUpdate
}
from
'
vs/code/electron-main/update-manager
'
;
import
{
ILogService
}
from
'
./log
'
;
import
{
ServiceIdentifier
,
createDecorator
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceIdentifier
,
createDecorator
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
const
EventTypes
=
{
OPEN
:
'
open
'
,
...
...
@@ -42,13 +41,13 @@ export interface IOpenConfiguration {
preferNewWindow
?:
boolean
;
forceNewWindow
?:
boolean
;
forceEmpty
?:
boolean
;
windowToUse
?:
window
.
VSCodeWindow
;
windowToUse
?:
VSCodeWindow
;
diffMode
?:
boolean
;
}
interface
IWindowState
{
workspacePath
?:
string
;
uiState
:
window
.
I
WindowState
;
uiState
:
ISingle
WindowState
;
}
interface
IWindowsState
{
...
...
@@ -79,27 +78,27 @@ export interface IWindowsService {
// TODO make proper events
// events
onOpen
(
clb
:
(
path
:
window
.
IPath
)
=>
void
):
()
=>
void
;
onReady
(
clb
:
(
win
:
window
.
VSCodeWindow
)
=>
void
):
()
=>
void
;
onOpen
(
clb
:
(
path
:
IPath
)
=>
void
):
()
=>
void
;
onReady
(
clb
:
(
win
:
VSCodeWindow
)
=>
void
):
()
=>
void
;
onClose
(
clb
:
(
id
:
number
)
=>
void
):
()
=>
void
;
// methods
ready
(
initialUserEnv
:
IProcessEnvironment
):
void
;
reload
(
win
:
window
.
VSCodeWindow
,
cli
?:
ICommandLineArguments
):
void
;
open
(
openConfig
:
IOpenConfiguration
):
window
.
VSCodeWindow
[];
reload
(
win
:
VSCodeWindow
,
cli
?:
ICommandLineArguments
):
void
;
open
(
openConfig
:
IOpenConfiguration
):
VSCodeWindow
[];
openPluginDevelopmentHostWindow
(
openConfig
:
IOpenConfiguration
):
void
;
openFileFolderPicker
(
forceNewWindow
?:
boolean
):
void
;
openFilePicker
(
forceNewWindow
?:
boolean
):
void
;
openFolderPicker
(
forceNewWindow
?:
boolean
):
void
;
focusLastActive
(
cli
:
ICommandLineArguments
):
window
.
VSCodeWindow
;
getLastActiveWindow
():
window
.
VSCodeWindow
;
findWindow
(
workspacePath
:
string
,
filePath
?:
string
,
extensionDevelopmentPath
?:
string
):
window
.
VSCodeWindow
;
focusLastActive
(
cli
:
ICommandLineArguments
):
VSCodeWindow
;
getLastActiveWindow
():
VSCodeWindow
;
findWindow
(
workspacePath
:
string
,
filePath
?:
string
,
extensionDevelopmentPath
?:
string
):
VSCodeWindow
;
openNewWindow
():
void
;
sendToFocused
(
channel
:
string
,
...
args
:
any
[]):
void
;
sendToAll
(
channel
:
string
,
payload
:
any
,
windowIdsToIgnore
?:
number
[]):
void
;
getFocusedWindow
():
window
.
VSCodeWindow
;
getWindowById
(
windowId
:
number
):
window
.
VSCodeWindow
;
getWindows
():
window
.
VSCodeWindow
[];
getFocusedWindow
():
VSCodeWindow
;
getWindowById
(
windowId
:
number
):
VSCodeWindow
;
getWindows
():
VSCodeWindow
[];
getWindowCount
():
number
;
}
...
...
@@ -112,29 +111,29 @@ export class WindowsManager implements IWindowsService {
private
static
workingDirPickerStorageKey
=
'
pickerWorkingDir
'
;
private
static
windowsStateStorageKey
=
'
windowsState
'
;
private
static
WINDOWS
:
window
.
VSCodeWindow
[]
=
[];
private
static
WINDOWS
:
VSCodeWindow
[]
=
[];
private
eventEmitter
=
new
events
.
EventEmitter
();
private
eventEmitter
=
new
EventEmitter
();
private
initialUserEnv
:
IProcessEnvironment
;
private
windowsState
:
IWindowsState
;
constructor
(
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
ILogService
private
logService
:
ILogService
,
@
storage
.
IStorageService
private
storageService
:
storage
.
IStorageService
,
@
IStorageService
private
storageService
:
IStorageService
,
@
IEnvironmentService
private
envService
:
IEnvironmentService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IUpdateService
private
updateManager
:
IUpdateService
,
@
ISettingsService
private
settingsManager
:
ISettingsService
)
{
}
onOpen
(
clb
:
(
path
:
window
.
IPath
)
=>
void
):
()
=>
void
{
onOpen
(
clb
:
(
path
:
IPath
)
=>
void
):
()
=>
void
{
this
.
eventEmitter
.
addListener
(
EventTypes
.
OPEN
,
clb
);
return
()
=>
this
.
eventEmitter
.
removeListener
(
EventTypes
.
OPEN
,
clb
);
}
onReady
(
clb
:
(
win
:
window
.
VSCodeWindow
)
=>
void
):
()
=>
void
{
onReady
(
clb
:
(
win
:
VSCodeWindow
)
=>
void
):
()
=>
void
{
this
.
eventEmitter
.
addListener
(
EventTypes
.
READY
,
clb
);
return
()
=>
this
.
eventEmitter
.
removeListener
(
EventTypes
.
READY
,
clb
);
...
...
@@ -350,9 +349,9 @@ export class WindowsManager implements IWindowsService {
this
.
logService
.
log
(
'
IPC#vscode:toggleMenuBar
'
);
// Update in settings
let
menuBarHidden
=
this
.
storageService
.
getItem
(
window
.
VSCodeWindow
.
menuBarHiddenKey
,
false
);
let
menuBarHidden
=
this
.
storageService
.
getItem
(
VSCodeWindow
.
menuBarHiddenKey
,
false
);
let
newMenuBarHidden
=
!
menuBarHidden
;
this
.
storageService
.
setItem
(
window
.
VSCodeWindow
.
menuBarHiddenKey
,
newMenuBarHidden
);
this
.
storageService
.
setItem
(
VSCodeWindow
.
menuBarHiddenKey
,
newMenuBarHidden
);
// Update across windows
WindowsManager
.
WINDOWS
.
forEach
(
w
=>
w
.
setMenuBarVisibility
(
!
newMenuBarHidden
));
...
...
@@ -451,7 +450,7 @@ export class WindowsManager implements IWindowsService {
}
// 2-N windows open: Keep a list of windows that are opened on a specific folder to restore it in the next session as needed
this
.
windowsState
.
openedFolders
=
WindowsManager
.
WINDOWS
.
filter
(
w
=>
w
.
readyState
===
window
.
ReadyState
.
READY
&&
!!
w
.
openedWorkspacePath
&&
!
w
.
isPluginDevelopmentHost
).
map
(
w
=>
{
this
.
windowsState
.
openedFolders
=
WindowsManager
.
WINDOWS
.
filter
(
w
=>
w
.
readyState
===
ReadyState
.
READY
&&
!!
w
.
openedWorkspacePath
&&
!
w
.
isPluginDevelopmentHost
).
map
(
w
=>
{
return
<
IWindowState
>
{
workspacePath
:
w
.
openedWorkspacePath
,
uiState
:
w
.
serializeWindowState
()
...
...
@@ -479,11 +478,11 @@ export class WindowsManager implements IWindowsService {
// Theme changes
if
(
event
===
'
vscode:changeTheme
'
&&
typeof
payload
===
'
string
'
)
{
this
.
storageService
.
setItem
(
window
.
VSCodeWindow
.
themeStorageKey
,
payload
);
this
.
storageService
.
setItem
(
VSCodeWindow
.
themeStorageKey
,
payload
);
}
}
public
reload
(
win
:
window
.
VSCodeWindow
,
cli
?:
ICommandLineArguments
):
void
{
public
reload
(
win
:
VSCodeWindow
,
cli
?:
ICommandLineArguments
):
void
{
// Only reload when the window has not vetoed this
this
.
lifecycleService
.
unload
(
win
).
done
((
veto
)
=>
{
...
...
@@ -493,9 +492,9 @@ export class WindowsManager implements IWindowsService {
});
}
public
open
(
openConfig
:
IOpenConfiguration
):
window
.
VSCodeWindow
[]
{
let
iPathsToOpen
:
window
.
IPath
[];
let
usedWindows
:
window
.
VSCodeWindow
[]
=
[];
public
open
(
openConfig
:
IOpenConfiguration
):
VSCodeWindow
[]
{
let
iPathsToOpen
:
IPath
[];
let
usedWindows
:
VSCodeWindow
[]
=
[];
// Find paths from provided paths if any
if
(
openConfig
.
pathsToOpen
&&
openConfig
.
pathsToOpen
.
length
>
0
)
{
...
...
@@ -543,8 +542,8 @@ export class WindowsManager implements IWindowsService {
iPathsToOpen
=
this
.
cliToPaths
(
openConfig
.
cli
,
ignoreFileNotFound
);
}
let
filesToOpen
:
window
.
IPath
[]
=
[];
let
filesToDiff
:
window
.
IPath
[]
=
[];
let
filesToOpen
:
IPath
[]
=
[];
let
filesToDiff
:
IPath
[]
=
[];
let
foldersToOpen
=
iPathsToOpen
.
filter
((
iPath
)
=>
iPath
.
workspacePath
&&
!
iPath
.
filePath
&&
!
iPath
.
installExtensionPath
);
let
emptyToOpen
=
iPathsToOpen
.
filter
((
iPath
)
=>
!
iPath
.
workspacePath
&&
!
iPath
.
filePath
&&
!
iPath
.
installExtensionPath
);
let
extensionsToInstall
=
iPathsToOpen
.
filter
((
iPath
)
=>
iPath
.
installExtensionPath
).
map
(
ipath
=>
ipath
.
filePath
);
...
...
@@ -565,7 +564,7 @@ export class WindowsManager implements IWindowsService {
filesToOpen
=
candidates
;
}
let
configuration
:
window
.
IWindowConfiguration
;
let
configuration
:
IWindowConfiguration
;
// Handle files to open/diff or to create when we dont open a folder
if
(
!
foldersToOpen
.
length
&&
(
filesToOpen
.
length
>
0
||
filesToCreate
.
length
>
0
||
filesToDiff
.
length
>
0
||
extensionsToInstall
.
length
>
0
))
{
...
...
@@ -719,8 +718,8 @@ export class WindowsManager implements IWindowsService {
this
.
open
({
cli
:
openConfig
.
cli
,
forceNewWindow
:
true
,
forceEmpty
:
openConfig
.
cli
.
pathArguments
.
length
===
0
});
}
private
toConfiguration
(
userEnv
:
IProcessEnvironment
,
cli
:
ICommandLineArguments
,
workspacePath
?:
string
,
filesToOpen
?:
window
.
IPath
[],
filesToCreate
?:
window
.
IPath
[],
filesToDiff
?:
window
.
IPath
[],
extensionsToInstall
?:
string
[]):
window
.
IWindowConfiguration
{
let
configuration
:
window
.
IWindowConfiguration
=
objects
.
mixin
({},
cli
);
// inherit all properties from CLI
private
toConfiguration
(
userEnv
:
IProcessEnvironment
,
cli
:
ICommandLineArguments
,
workspacePath
?:
string
,
filesToOpen
?:
IPath
[],
filesToCreate
?:
IPath
[],
filesToDiff
?:
IPath
[],
extensionsToInstall
?:
string
[]):
IWindowConfiguration
{
let
configuration
:
IWindowConfiguration
=
objects
.
mixin
({},
cli
);
// inherit all properties from CLI
configuration
.
execPath
=
process
.
execPath
;
configuration
.
workspacePath
=
workspacePath
;
configuration
.
filesToOpen
=
filesToOpen
;
...
...
@@ -761,7 +760,7 @@ export class WindowsManager implements IWindowsService {
return
configuration
;
}
private
getRecentlyOpenedPaths
(
workspacePath
?:
string
,
filesToOpen
?:
window
.
IPath
[]):
IOpenedPathsList
{
private
getRecentlyOpenedPaths
(
workspacePath
?:
string
,
filesToOpen
?:
IPath
[]):
IOpenedPathsList
{
let
files
:
string
[];
let
folders
:
string
[];
...
...
@@ -800,7 +799,7 @@ export class WindowsManager implements IWindowsService {
return
{
files
,
folders
};
}
private
toIPath
(
anyPath
:
string
,
ignoreFileNotFound
?:
boolean
,
gotoLineMode
?:
boolean
):
window
.
IPath
{
private
toIPath
(
anyPath
:
string
,
ignoreFileNotFound
?:
boolean
,
gotoLineMode
?:
boolean
):
IPath
{
if
(
!
anyPath
)
{
return
null
;
}
...
...
@@ -833,7 +832,7 @@ export class WindowsManager implements IWindowsService {
return
null
;
}
private
cliToPaths
(
cli
:
ICommandLineArguments
,
ignoreFileNotFound
?:
boolean
):
window
.
IPath
[]
{
private
cliToPaths
(
cli
:
ICommandLineArguments
,
ignoreFileNotFound
?:
boolean
):
IPath
[]
{
// Check for pass in candidate or last opened path
let
candidates
:
string
[]
=
[];
...
...
@@ -874,8 +873,8 @@ export class WindowsManager implements IWindowsService {
return
[
Object
.
create
(
null
)];
}
private
openInBrowserWindow
(
configuration
:
window
.
IWindowConfiguration
,
forceNewWindow
?:
boolean
,
windowToUse
?:
window
.
VSCodeWindow
):
window
.
VSCodeWindow
{
let
vscodeWindow
:
window
.
VSCodeWindow
;
private
openInBrowserWindow
(
configuration
:
IWindowConfiguration
,
forceNewWindow
?:
boolean
,
windowToUse
?:
VSCodeWindow
):
VSCodeWindow
{
let
vscodeWindow
:
VSCodeWindow
;
if
(
!
forceNewWindow
)
{
vscodeWindow
=
windowToUse
||
this
.
getLastActiveWindow
();
...
...
@@ -887,7 +886,7 @@ export class WindowsManager implements IWindowsService {
// New window
if
(
!
vscodeWindow
)
{
vscodeWindow
=
this
.
instantiationService
.
createInstance
(
window
.
VSCodeWindow
,
{
vscodeWindow
=
this
.
instantiationService
.
createInstance
(
VSCodeWindow
,
{
state
:
this
.
getNewWindowState
(
configuration
),
extensionDevelopmentPath
:
configuration
.
extensionDevelopmentPath
});
...
...
@@ -935,7 +934,7 @@ export class WindowsManager implements IWindowsService {
return
vscodeWindow
;
}
private
getNewWindowState
(
configuration
:
window
.
IWindowConfiguration
):
window
.
I
WindowState
{
private
getNewWindowState
(
configuration
:
IWindowConfiguration
):
ISingle
WindowState
{
// plugin development host Window - load from stored settings if any
if
(
!!
configuration
.
extensionDevelopmentPath
&&
this
.
windowsState
.
lastPluginDevelopmentHostWindow
)
{
...
...
@@ -989,14 +988,14 @@ export class WindowsManager implements IWindowsService {
}
}
let
defaultState
=
window
.
defaultWindowState
();
let
defaultState
=
defaultWindowState
();
defaultState
.
x
=
displayToUse
.
bounds
.
x
+
(
displayToUse
.
bounds
.
width
/
2
)
-
(
defaultState
.
width
/
2
);
defaultState
.
y
=
displayToUse
.
bounds
.
y
+
(
displayToUse
.
bounds
.
height
/
2
)
-
(
defaultState
.
height
/
2
);
return
this
.
ensureNoOverlap
(
defaultState
);
}
private
ensureNoOverlap
(
state
:
window
.
IWindowState
):
window
.
I
WindowState
{
private
ensureNoOverlap
(
state
:
ISingleWindowState
):
ISingle
WindowState
{
if
(
WindowsManager
.
WINDOWS
.
length
===
0
)
{
return
state
;
}
...
...
@@ -1058,7 +1057,7 @@ export class WindowsManager implements IWindowsService {
});
}
public
focusLastActive
(
cli
:
ICommandLineArguments
):
window
.
VSCodeWindow
{
public
focusLastActive
(
cli
:
ICommandLineArguments
):
VSCodeWindow
{
let
lastActive
=
this
.
getLastActiveWindow
();
if
(
lastActive
)
{
lastActive
.
focus
();
...
...
@@ -1073,7 +1072,7 @@ export class WindowsManager implements IWindowsService {
return
res
&&
res
[
0
];
}
public
getLastActiveWindow
():
window
.
VSCodeWindow
{
public
getLastActiveWindow
():
VSCodeWindow
{
if
(
WindowsManager
.
WINDOWS
.
length
)
{
let
lastFocussedDate
=
Math
.
max
.
apply
(
Math
,
WindowsManager
.
WINDOWS
.
map
((
w
)
=>
w
.
lastFocusTime
));
let
res
=
WindowsManager
.
WINDOWS
.
filter
((
w
)
=>
w
.
lastFocusTime
===
lastFocussedDate
);
...
...
@@ -1085,7 +1084,7 @@ export class WindowsManager implements IWindowsService {
return
null
;
}
public
findWindow
(
workspacePath
:
string
,
filePath
?:
string
,
extensionDevelopmentPath
?:
string
):
window
.
VSCodeWindow
{
public
findWindow
(
workspacePath
:
string
,
filePath
?:
string
,
extensionDevelopmentPath
?:
string
):
VSCodeWindow
{
if
(
WindowsManager
.
WINDOWS
.
length
)
{
// Sort the last active window to the front of the array of windows to test
...
...
@@ -1152,7 +1151,7 @@ export class WindowsManager implements IWindowsService {
});
}
public
getFocusedWindow
():
window
.
VSCodeWindow
{
public
getFocusedWindow
():
VSCodeWindow
{
let
win
=
BrowserWindow
.
getFocusedWindow
();
if
(
win
)
{
return
this
.
getWindowById
(
win
.
id
);
...
...
@@ -1161,7 +1160,7 @@ export class WindowsManager implements IWindowsService {
return
null
;
}
public
getWindowById
(
windowId
:
number
):
window
.
VSCodeWindow
{
public
getWindowById
(
windowId
:
number
):
VSCodeWindow
{
let
res
=
WindowsManager
.
WINDOWS
.
filter
((
w
)
=>
w
.
id
===
windowId
);
if
(
res
&&
res
.
length
===
1
)
{
return
res
[
0
];
...
...
@@ -1170,7 +1169,7 @@ export class WindowsManager implements IWindowsService {
return
null
;
}
public
getWindows
():
window
.
VSCodeWindow
[]
{
public
getWindows
():
VSCodeWindow
[]
{
return
WindowsManager
.
WINDOWS
;
}
...
...
@@ -1178,7 +1177,7 @@ export class WindowsManager implements IWindowsService {
return
WindowsManager
.
WINDOWS
.
length
;
}
private
onWindowError
(
vscodeWindow
:
window
.
VSCodeWindow
,
error
:
WindowError
):
void
{
private
onWindowError
(
vscodeWindow
:
VSCodeWindow
,
error
:
WindowError
):
void
{
console
.
error
(
error
===
WindowError
.
CRASHED
?
'
[VS Code]: render process crashed!
'
:
'
[VS Code]: detected unresponsive
'
);
// Unresponsive
...
...
@@ -1220,8 +1219,8 @@ export class WindowsManager implements IWindowsService {
}
}
private
onBeforeWindowClose
(
win
:
window
.
VSCodeWindow
):
void
{
if
(
win
.
readyState
!==
window
.
ReadyState
.
READY
)
{
private
onBeforeWindowClose
(
win
:
VSCodeWindow
):
void
{
if
(
win
.
readyState
!==
ReadyState
.
READY
)
{
return
;
// only persist windows that are fully loaded
}
...
...
@@ -1240,7 +1239,7 @@ export class WindowsManager implements IWindowsService {
}
}
private
onWindowClosed
(
win
:
window
.
VSCodeWindow
):
void
{
private
onWindowClosed
(
win
:
VSCodeWindow
):
void
{
// Tell window
win
.
dispose
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录