Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bb55f060
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
bb55f060
编写于
8月 18, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mr - migrate backups when entering workspace
上级
1de0401b
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
168 addition
and
64 deletion
+168
-64
src/vs/code/electron-main/window.ts
src/vs/code/electron-main/window.ts
+7
-3
src/vs/code/electron-main/windows.ts
src/vs/code/electron-main/windows.ts
+73
-33
src/vs/platform/backup/common/backup.ts
src/vs/platform/backup/common/backup.ts
+1
-1
src/vs/platform/backup/electron-main/backupMainService.ts
src/vs/platform/backup/electron-main/backupMainService.ts
+20
-2
src/vs/platform/backup/test/electron-main/backupMainService.test.ts
...tform/backup/test/electron-main/backupMainService.test.ts
+15
-0
src/vs/platform/lifecycle/electron-main/lifecycleMain.ts
src/vs/platform/lifecycle/electron-main/lifecycleMain.ts
+15
-15
src/vs/platform/windows/common/windows.ts
src/vs/platform/windows/common/windows.ts
+2
-0
src/vs/platform/windows/common/windowsIpc.ts
src/vs/platform/windows/common/windowsIpc.ts
+6
-0
src/vs/platform/windows/electron-browser/windowService.ts
src/vs/platform/windows/electron-browser/windowService.ts
+4
-0
src/vs/platform/windows/electron-main/windows.ts
src/vs/platform/windows/electron-main/windows.ts
+1
-0
src/vs/platform/windows/electron-main/windowsService.ts
src/vs/platform/windows/electron-main/windowsService.ts
+10
-0
src/vs/workbench/browser/actions/workspaceActions.ts
src/vs/workbench/browser/actions/workspaceActions.ts
+6
-10
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+8
-0
未找到文件。
src/vs/code/electron-main/window.ts
浏览文件 @
bb55f060
...
...
@@ -511,10 +511,14 @@ export class CodeWindow implements ICodeWindow {
}
}
public
reload
(
cli
?:
ParsedArgs
):
void
{
public
reload
(
c
onfiguration
?:
IWindowConfiguration
,
c
li
?:
ParsedArgs
):
void
{
// Inherit current properties but overwrite some
const
configuration
:
IWindowConfiguration
=
objects
.
mixin
({},
this
.
currentConfig
);
// If config is not provided, copy our current one
if
(
!
configuration
)
{
configuration
=
objects
.
mixin
({},
this
.
currentConfig
);
}
// Delete some properties we do not want during reload
delete
configuration
.
filesToOpen
;
delete
configuration
.
filesToCreate
;
delete
configuration
.
filesToDiff
;
...
...
src/vs/code/electron-main/windows.ts
浏览文件 @
bb55f060
...
...
@@ -19,7 +19,7 @@ import { IPathWithLineAndColumn, parseLineAndColumnAware } from 'vs/code/node/pa
import
{
ILifecycleService
,
UnloadReason
,
IWindowUnloadEvent
}
from
'
vs/platform/lifecycle/electron-main/lifecycleMain
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IWindowSettings
,
OpenContext
,
IPath
,
IWindowConfiguration
,
INativeOpenDialogOptions
}
from
'
vs/platform/windows/common/windows
'
;
import
{
IWindowSettings
,
OpenContext
,
IPath
,
IWindowConfiguration
,
INativeOpenDialogOptions
,
ReadyState
}
from
'
vs/platform/windows/common/windows
'
;
import
{
getLastActiveWindow
,
findBestWindowOrFolderForFile
,
findWindowOnWorkspace
,
findWindowOnExtensionDevelopmentPath
,
findWindowOnWorkspaceOrFolderPath
}
from
'
vs/code/node/windowsFinder
'
;
import
CommonEvent
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
product
from
'
vs/platform/node/product
'
;
...
...
@@ -937,16 +937,16 @@ export class WindowsManager implements IWindowsMainService {
configuration
.
backupPath
=
path
.
join
(
this
.
environmentService
.
backupHome
,
options
.
emptyWindowBackupFolder
);
}
let
codeW
indow
:
CodeWindow
;
let
w
indow
:
CodeWindow
;
if
(
!
options
.
forceNewWindow
)
{
codeW
indow
=
options
.
windowToUse
||
this
.
getLastActiveWindow
();
if
(
codeW
indow
)
{
codeW
indow
.
focus
();
w
indow
=
options
.
windowToUse
||
this
.
getLastActiveWindow
();
if
(
w
indow
)
{
w
indow
.
focus
();
}
}
// New window
if
(
!
codeW
indow
)
{
if
(
!
w
indow
)
{
const
windowConfig
=
this
.
configurationService
.
getConfiguration
<
IWindowSettings
>
(
'
window
'
);
const
state
=
this
.
getNewWindowState
(
configuration
);
...
...
@@ -965,27 +965,27 @@ export class WindowsManager implements IWindowsMainService {
state
.
mode
=
WindowMode
.
Normal
;
}
codeW
indow
=
this
.
instantiationService
.
createInstance
(
CodeWindow
,
{
w
indow
=
this
.
instantiationService
.
createInstance
(
CodeWindow
,
{
state
,
extensionDevelopmentPath
:
configuration
.
extensionDevelopmentPath
,
isExtensionTestHost
:
!!
configuration
.
extensionTestsPath
});
// Add to our list of windows
WindowsManager
.
WINDOWS
.
push
(
codeW
indow
);
WindowsManager
.
WINDOWS
.
push
(
w
indow
);
// Indicate number change via event
this
.
_onWindowsCountChanged
.
fire
({
oldCount
:
WindowsManager
.
WINDOWS
.
length
-
1
,
newCount
:
WindowsManager
.
WINDOWS
.
length
});
// Window Events
codeW
indow
.
win
.
webContents
.
removeAllListeners
(
'
devtools-reload-page
'
);
// remove built in listener so we can handle this on our own
codeWindow
.
win
.
webContents
.
on
(
'
devtools-reload-page
'
,
()
=>
this
.
reload
(
codeW
indow
));
codeWindow
.
win
.
webContents
.
on
(
'
crashed
'
,
()
=>
this
.
onWindowError
(
codeW
indow
,
WindowError
.
CRASHED
));
codeWindow
.
win
.
on
(
'
unresponsive
'
,
()
=>
this
.
onWindowError
(
codeW
indow
,
WindowError
.
UNRESPONSIVE
));
codeWindow
.
win
.
on
(
'
closed
'
,
()
=>
this
.
onWindowClosed
(
codeW
indow
));
w
indow
.
win
.
webContents
.
removeAllListeners
(
'
devtools-reload-page
'
);
// remove built in listener so we can handle this on our own
window
.
win
.
webContents
.
on
(
'
devtools-reload-page
'
,
()
=>
this
.
reload
(
w
indow
));
window
.
win
.
webContents
.
on
(
'
crashed
'
,
()
=>
this
.
onWindowError
(
w
indow
,
WindowError
.
CRASHED
));
window
.
win
.
on
(
'
unresponsive
'
,
()
=>
this
.
onWindowError
(
w
indow
,
WindowError
.
UNRESPONSIVE
));
window
.
win
.
on
(
'
closed
'
,
()
=>
this
.
onWindowClosed
(
w
indow
));
// Lifecycle
this
.
lifecycleService
.
registerWindow
(
codeW
indow
);
this
.
lifecycleService
.
registerWindow
(
w
indow
);
}
// Existing window
...
...
@@ -993,7 +993,7 @@ export class WindowsManager implements IWindowsMainService {
// Some configuration things get inherited if the window is being reused and we are
// in extension development host mode. These options are all development related.
const
currentWindowConfig
=
codeW
indow
.
config
;
const
currentWindowConfig
=
w
indow
.
config
;
if
(
!
configuration
.
extensionDevelopmentPath
&&
currentWindowConfig
&&
!!
currentWindowConfig
.
extensionDevelopmentPath
)
{
configuration
.
extensionDevelopmentPath
=
currentWindowConfig
.
extensionDevelopmentPath
;
configuration
.
verbose
=
currentWindowConfig
.
verbose
;
...
...
@@ -1005,7 +1005,7 @@ export class WindowsManager implements IWindowsMainService {
}
// Only load when the window has not vetoed this
this
.
lifecycleService
.
unload
(
codeW
indow
,
UnloadReason
.
LOAD
).
done
(
veto
=>
{
this
.
lifecycleService
.
unload
(
w
indow
,
UnloadReason
.
LOAD
).
done
(
veto
=>
{
if
(
!
veto
)
{
// Register window for backups
...
...
@@ -1020,11 +1020,11 @@ export class WindowsManager implements IWindowsMainService {
}
// Load it
codeW
indow
.
load
(
configuration
);
w
indow
.
load
(
configuration
);
}
});
return
codeW
indow
;
return
w
indow
;
}
private
getNewWindowState
(
configuration
:
IWindowConfiguration
):
INewWindowState
{
...
...
@@ -1156,7 +1156,7 @@ export class WindowsManager implements IWindowsMainService {
// Only reload when the window has not vetoed this
this
.
lifecycleService
.
unload
(
win
,
UnloadReason
.
RELOAD
).
done
(
veto
=>
{
if
(
!
veto
)
{
win
.
reload
(
cli
);
win
.
reload
(
void
0
,
cli
);
// Emit
this
.
_onWindowReload
.
fire
(
win
.
id
);
...
...
@@ -1171,6 +1171,46 @@ export class WindowsManager implements IWindowsMainService {
});
}
public
createAndOpenWorkspace
(
window
:
CodeWindow
,
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
{
if
(
!
window
||
!
window
.
win
||
window
.
readyState
!==
ReadyState
.
READY
)
{
return
TPromise
.
as
(
null
);
// return early if the window is not ready or disposed
}
return
this
.
workspacesService
.
createWorkspace
(
folders
).
then
(
workspace
=>
{
let
savePromise
:
TPromise
<
IWorkspaceIdentifier
>
;
if
(
path
)
{
savePromise
=
this
.
workspacesService
.
saveWorkspace
(
workspace
,
path
);
}
else
{
savePromise
=
TPromise
.
as
(
workspace
);
}
return
savePromise
.
then
(
workspace
=>
{
window
.
focus
();
// Only open workspace when the window has not vetoed this
return
this
.
lifecycleService
.
unload
(
window
,
UnloadReason
.
RELOAD
).
done
(
veto
=>
{
if
(
!
veto
)
{
// Register window for backups and migrate current backups over
let
backupPath
:
string
;
if
(
window
.
config
&&
!
window
.
config
.
extensionDevelopmentPath
)
{
backupPath
=
this
.
backupService
.
registerWorkspaceBackupSync
(
workspace
,
window
.
config
.
backupPath
);
}
// Craft a new window configuration to use for the transition
const
configuration
:
IWindowConfiguration
=
mixin
({},
window
.
config
);
configuration
.
folderPath
=
void
0
;
configuration
.
workspace
=
workspace
;
configuration
.
backupPath
=
backupPath
;
// Reload
window
.
reload
(
configuration
);
}
});
});
});
}
public
openWorkspace
(
window
:
CodeWindow
=
this
.
getLastActiveWindow
()):
void
{
let
defaultPath
:
string
;
if
(
window
&&
window
.
openedWorkspace
&&
!
this
.
workspacesService
.
isUntitledWorkspace
(
window
.
openedWorkspace
))
{
...
...
@@ -1380,12 +1420,12 @@ export class WindowsManager implements IWindowsMainService {
return
WindowsManager
.
WINDOWS
.
length
;
}
private
onWindowError
(
codeW
indow
:
CodeWindow
,
error
:
WindowError
):
void
{
private
onWindowError
(
w
indow
:
CodeWindow
,
error
:
WindowError
):
void
{
this
.
logService
.
error
(
error
===
WindowError
.
CRASHED
?
'
[VS Code]: render process crashed!
'
:
'
[VS Code]: detected unresponsive
'
);
// Unresponsive
if
(
error
===
WindowError
.
UNRESPONSIVE
)
{
dialog
.
showMessageBox
(
codeW
indow
.
win
,
{
dialog
.
showMessageBox
(
w
indow
.
win
,
{
title
:
product
.
nameLong
,
type
:
'
warning
'
,
buttons
:
[
localize
(
'
reopen
'
,
"
Reopen
"
),
localize
(
'
wait
'
,
"
Keep Waiting
"
),
localize
(
'
close
'
,
"
Close
"
)],
...
...
@@ -1393,22 +1433,22 @@ export class WindowsManager implements IWindowsMainService {
detail
:
localize
(
'
appStalledDetail
'
,
"
You can reopen or close the window or keep waiting.
"
),
noLink
:
true
},
result
=>
{
if
(
!
codeW
indow
.
win
)
{
if
(
!
w
indow
.
win
)
{
return
;
// Return early if the window has been going down already
}
if
(
result
===
0
)
{
codeW
indow
.
reload
();
w
indow
.
reload
();
}
else
if
(
result
===
2
)
{
this
.
onBeforeWindowClose
(
codeW
indow
);
// 'close' event will not be fired on destroy(), so run it manually
codeW
indow
.
win
.
destroy
();
// make sure to destroy the window as it is unresponsive
this
.
onBeforeWindowClose
(
w
indow
);
// 'close' event will not be fired on destroy(), so run it manually
w
indow
.
win
.
destroy
();
// make sure to destroy the window as it is unresponsive
}
});
}
// Crashed
else
{
dialog
.
showMessageBox
(
codeW
indow
.
win
,
{
dialog
.
showMessageBox
(
w
indow
.
win
,
{
title
:
product
.
nameLong
,
type
:
'
warning
'
,
buttons
:
[
localize
(
'
reopen
'
,
"
Reopen
"
),
localize
(
'
close
'
,
"
Close
"
)],
...
...
@@ -1416,15 +1456,15 @@ export class WindowsManager implements IWindowsMainService {
detail
:
localize
(
'
appCrashedDetail
'
,
"
We are sorry for the inconvenience! You can reopen the window to continue where you left off.
"
),
noLink
:
true
},
result
=>
{
if
(
!
codeW
indow
.
win
)
{
if
(
!
w
indow
.
win
)
{
return
;
// Return early if the window has been going down already
}
if
(
result
===
0
)
{
codeW
indow
.
reload
();
w
indow
.
reload
();
}
else
if
(
result
===
1
)
{
this
.
onBeforeWindowClose
(
codeW
indow
);
// 'close' event will not be fired on destroy(), so run it manually
codeW
indow
.
win
.
destroy
();
// make sure to destroy the window as it has crashed
this
.
onBeforeWindowClose
(
w
indow
);
// 'close' event will not be fired on destroy(), so run it manually
w
indow
.
win
.
destroy
();
// make sure to destroy the window as it has crashed
}
});
}
...
...
@@ -1493,9 +1533,9 @@ export class WindowsManager implements IWindowsMainService {
// If the user selected to exit from an extension development host window, do not quit, but just
// close the window unless this is the last window that is opened.
const
codeW
indow
=
this
.
getFocusedWindow
();
if
(
codeWindow
&&
codeW
indow
.
isExtensionDevelopmentHost
&&
this
.
getWindowCount
()
>
1
)
{
codeW
indow
.
win
.
close
();
const
w
indow
=
this
.
getFocusedWindow
();
if
(
window
&&
w
indow
.
isExtensionDevelopmentHost
&&
this
.
getWindowCount
()
>
1
)
{
w
indow
.
win
.
close
();
}
// Otherwise: normal quit
...
...
src/vs/platform/backup/common/backup.ts
浏览文件 @
bb55f060
...
...
@@ -23,7 +23,7 @@ export interface IBackupMainService {
getFolderBackupPaths
():
string
[];
getEmptyWindowBackupPaths
():
string
[];
registerWorkspaceBackupSync
(
workspace
:
IWorkspaceIdentifier
):
string
;
registerWorkspaceBackupSync
(
workspace
:
IWorkspaceIdentifier
,
migrateFrom
?:
string
):
string
;
registerFolderBackupSync
(
folderPath
:
string
):
string
;
registerEmptyWindowBackupSync
(
backupFolder
?:
string
):
string
;
}
\ No newline at end of file
src/vs/platform/backup/electron-main/backupMainService.ts
浏览文件 @
bb55f060
...
...
@@ -97,10 +97,28 @@ export class BackupMainService implements IBackupMainService {
return
this
.
backups
.
emptyWorkspaces
.
slice
(
0
);
// return a copy
}
public
registerWorkspaceBackupSync
(
workspace
:
IWorkspaceIdentifier
):
string
{
public
registerWorkspaceBackupSync
(
workspace
:
IWorkspaceIdentifier
,
migrateFrom
?:
string
):
string
{
this
.
pushBackupPathsSync
(
workspace
,
this
.
backups
.
rootWorkspaces
);
return
path
.
join
(
this
.
backupHome
,
workspace
.
id
);
const
backupPath
=
path
.
join
(
this
.
backupHome
,
workspace
.
id
);
if
(
migrateFrom
)
{
this
.
moveBackupFolderSync
(
backupPath
,
migrateFrom
);
}
return
backupPath
;
}
private
moveBackupFolderSync
(
backupPath
:
string
,
moveFromPath
:
string
):
void
{
if
(
!
fs
.
existsSync
(
moveFromPath
))
{
return
;
}
try
{
fs
.
renameSync
(
moveFromPath
,
backupPath
);
}
catch
(
ex
)
{
this
.
logService
.
error
(
`Backup: Could not move backup folder to new location:
${
ex
.
toString
()}
`
);
}
}
public
registerFolderBackupSync
(
folderPath
:
string
):
string
{
...
...
src/vs/platform/backup/test/electron-main/backupMainService.test.ts
浏览文件 @
bb55f060
...
...
@@ -196,6 +196,21 @@ suite('BackupMainService', () => {
done
();
});
test
(
'
service supports to migrate backup data from another location
'
,
done
=>
{
const
backupPathToMigrate
=
service
.
toBackupPath
(
fooFile
.
fsPath
);
fs
.
mkdirSync
(
backupPathToMigrate
);
fs
.
writeFileSync
(
path
.
join
(
backupPathToMigrate
,
'
backup.txt
'
),
'
Some Data
'
);
service
.
registerFolderBackupSync
(
backupPathToMigrate
);
const
workspaceBackupPath
=
service
.
registerWorkspaceBackupSync
(
toWorkspace
(
barFile
.
fsPath
),
backupPathToMigrate
);
assert
.
ok
(
fs
.
existsSync
(
workspaceBackupPath
));
assert
.
ok
(
fs
.
existsSync
(
path
.
join
(
workspaceBackupPath
,
'
backup.txt
'
)));
assert
.
ok
(
!
fs
.
existsSync
(
backupPathToMigrate
));
done
();
});
suite
(
'
loadSync
'
,
()
=>
{
test
(
'
getFolderBackupPaths() should return [] when workspaces.json doesn
\'
t exist
'
,
()
=>
{
assert
.
deepEqual
(
service
.
getFolderBackupPaths
(),
[]);
...
...
src/vs/platform/lifecycle/electron-main/lifecycleMain.ts
浏览文件 @
bb55f060
...
...
@@ -59,9 +59,9 @@ export interface ILifecycleService {
onBeforeWindowUnload
:
Event
<
IWindowUnloadEvent
>
;
ready
():
void
;
registerWindow
(
codeW
indow
:
ICodeWindow
):
void
;
registerWindow
(
w
indow
:
ICodeWindow
):
void
;
unload
(
codeW
indow
:
ICodeWindow
,
reason
:
UnloadReason
):
TPromise
<
boolean
/* veto */
>
;
unload
(
w
indow
:
ICodeWindow
,
reason
:
UnloadReason
):
TPromise
<
boolean
/* veto */
>
;
relaunch
(
options
?:
{
addArgs
?:
string
[],
removeArgs
?:
string
[]
});
...
...
@@ -148,11 +148,11 @@ export class LifecycleService implements ILifecycleService {
});
}
public
registerWindow
(
codeW
indow
:
ICodeWindow
):
void
{
public
registerWindow
(
w
indow
:
ICodeWindow
):
void
{
// Window Before Closing: Main -> Renderer
codeW
indow
.
win
.
on
(
'
close
'
,
e
=>
{
const
windowId
=
codeW
indow
.
id
;
w
indow
.
win
.
on
(
'
close
'
,
e
=>
{
const
windowId
=
w
indow
.
id
;
this
.
logService
.
log
(
'
Lifecycle#window-before-close
'
,
windowId
);
// The window already acknowledged to be closed
...
...
@@ -166,11 +166,11 @@ export class LifecycleService implements ILifecycleService {
// Otherwise prevent unload and handle it from window
e
.
preventDefault
();
this
.
unload
(
codeW
indow
,
UnloadReason
.
CLOSE
).
done
(
veto
=>
{
this
.
unload
(
w
indow
,
UnloadReason
.
CLOSE
).
done
(
veto
=>
{
if
(
!
veto
)
{
this
.
windowToCloseRequest
[
windowId
]
=
true
;
this
.
_onBeforeWindowClose
.
fire
(
codeW
indow
);
codeW
indow
.
close
();
this
.
_onBeforeWindowClose
.
fire
(
w
indow
);
w
indow
.
close
();
}
else
{
this
.
quitRequested
=
false
;
delete
this
.
windowToCloseRequest
[
windowId
];
...
...
@@ -179,25 +179,25 @@ export class LifecycleService implements ILifecycleService {
});
}
public
unload
(
codeW
indow
:
ICodeWindow
,
reason
:
UnloadReason
):
TPromise
<
boolean
/* veto */
>
{
public
unload
(
w
indow
:
ICodeWindow
,
reason
:
UnloadReason
):
TPromise
<
boolean
/* veto */
>
{
// Always allow to unload a window that is not yet ready
if
(
codeW
indow
.
readyState
!==
ReadyState
.
READY
)
{
if
(
w
indow
.
readyState
!==
ReadyState
.
READY
)
{
return
TPromise
.
as
<
boolean
>
(
false
);
}
this
.
logService
.
log
(
'
Lifecycle#unload()
'
,
codeW
indow
.
id
);
this
.
logService
.
log
(
'
Lifecycle#unload()
'
,
w
indow
.
id
);
const
windowUnloadReason
=
this
.
quitRequested
?
UnloadReason
.
QUIT
:
reason
;
// first ask the window itself if it vetos the unload
return
this
.
doUnloadWindowInRenderer
(
codeW
indow
,
windowUnloadReason
).
then
(
veto
=>
{
return
this
.
doUnloadWindowInRenderer
(
w
indow
,
windowUnloadReason
).
then
(
veto
=>
{
if
(
veto
)
{
return
this
.
handleVeto
(
veto
);
}
// then check for vetos in the main side
return
this
.
doUnloadWindowInMain
(
codeW
indow
,
windowUnloadReason
).
then
(
veto
=>
this
.
handleVeto
(
veto
));
return
this
.
doUnloadWindowInMain
(
w
indow
,
windowUnloadReason
).
then
(
veto
=>
this
.
handleVeto
(
veto
));
});
}
...
...
@@ -213,7 +213,7 @@ export class LifecycleService implements ILifecycleService {
return
veto
;
}
private
doUnloadWindowInRenderer
(
codeW
indow
:
ICodeWindow
,
reason
:
UnloadReason
):
TPromise
<
boolean
/* veto */
>
{
private
doUnloadWindowInRenderer
(
w
indow
:
ICodeWindow
,
reason
:
UnloadReason
):
TPromise
<
boolean
/* veto */
>
{
return
new
TPromise
<
boolean
>
((
c
)
=>
{
const
oneTimeEventToken
=
this
.
oneTimeListenerTokenGenerator
++
;
const
okChannel
=
`vscode:ok
${
oneTimeEventToken
}
`
;
...
...
@@ -227,7 +227,7 @@ export class LifecycleService implements ILifecycleService {
c
(
true
);
// veto
});
codeW
indow
.
send
(
'
vscode:beforeUnload
'
,
{
okChannel
,
cancelChannel
,
reason
});
w
indow
.
send
(
'
vscode:beforeUnload
'
,
{
okChannel
,
cancelChannel
,
reason
});
});
}
...
...
src/vs/platform/windows/common/windows.ts
浏览文件 @
bb55f060
...
...
@@ -42,6 +42,7 @@ export interface IWindowsService {
toggleDevTools
(
windowId
:
number
):
TPromise
<
void
>
;
closeWorkspace
(
windowId
:
number
):
TPromise
<
void
>
;
openWorkspace
(
windowId
:
number
):
TPromise
<
void
>
;
createAndOpenWorkspace
(
windowId
:
number
,
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
;
toggleFullScreen
(
windowId
:
number
):
TPromise
<
void
>
;
setRepresentedFilename
(
windowId
:
number
,
fileName
:
string
):
TPromise
<
void
>
;
addRecentlyOpened
(
files
:
string
[]):
TPromise
<
void
>
;
...
...
@@ -97,6 +98,7 @@ export interface IWindowService {
toggleDevTools
():
TPromise
<
void
>
;
closeWorkspace
():
TPromise
<
void
>
;
openWorkspace
():
TPromise
<
void
>
;
createAndOpenWorkspace
(
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
;
toggleFullScreen
():
TPromise
<
void
>
;
setRepresentedFilename
(
fileName
:
string
):
TPromise
<
void
>
;
getRecentlyOpened
():
TPromise
<
IRecentlyOpened
>
;
...
...
src/vs/platform/windows/common/windowsIpc.ts
浏览文件 @
bb55f060
...
...
@@ -23,6 +23,7 @@ export interface IWindowsChannel extends IChannel {
call
(
command
:
'
toggleDevTools
'
,
arg
:
number
):
TPromise
<
void
>
;
call
(
command
:
'
closeWorkspace
'
,
arg
:
number
):
TPromise
<
void
>
;
call
(
command
:
'
openWorkspace
'
,
arg
:
number
):
TPromise
<
void
>
;
call
(
command
:
'
createAndOpenWorkspace
'
,
arg
:
[
number
,
string
[],
string
]):
TPromise
<
void
>
;
call
(
command
:
'
toggleFullScreen
'
,
arg
:
number
):
TPromise
<
void
>
;
call
(
command
:
'
setRepresentedFilename
'
,
arg
:
[
number
,
string
]):
TPromise
<
void
>
;
call
(
command
:
'
addRecentlyOpened
'
,
arg
:
string
[]):
TPromise
<
void
>
;
...
...
@@ -78,6 +79,7 @@ export class WindowsChannel implements IWindowsChannel {
case
'
toggleDevTools
'
:
return
this
.
service
.
toggleDevTools
(
arg
);
case
'
closeWorkspace
'
:
return
this
.
service
.
closeWorkspace
(
arg
);
case
'
openWorkspace
'
:
return
this
.
service
.
openWorkspace
(
arg
);
case
'
createAndOpenWorkspace
'
:
return
this
.
service
.
createAndOpenWorkspace
(
arg
[
0
],
arg
[
1
],
arg
[
2
]);
case
'
toggleFullScreen
'
:
return
this
.
service
.
toggleFullScreen
(
arg
);
case
'
setRepresentedFilename
'
:
return
this
.
service
.
setRepresentedFilename
(
arg
[
0
],
arg
[
1
]);
case
'
addRecentlyOpened
'
:
return
this
.
service
.
addRecentlyOpened
(
arg
);
...
...
@@ -157,6 +159,10 @@ export class WindowsChannelClient implements IWindowsService {
return
this
.
channel
.
call
(
'
openWorkspace
'
,
windowId
);
}
createAndOpenWorkspace
(
windowId
:
number
,
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
createAndOpenWorkspace
'
,
[
windowId
,
folders
,
path
]);
}
toggleFullScreen
(
windowId
:
number
):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
toggleFullScreen
'
,
windowId
);
}
...
...
src/vs/platform/windows/electron-browser/windowService.ts
浏览文件 @
bb55f060
...
...
@@ -68,6 +68,10 @@ export class WindowService implements IWindowService {
return
this
.
windowsService
.
openWorkspace
(
this
.
windowId
);
}
createAndOpenWorkspace
(
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
{
return
this
.
windowsService
.
createAndOpenWorkspace
(
this
.
windowId
,
folders
,
path
);
}
closeWindow
():
TPromise
<
void
>
{
return
this
.
windowsService
.
closeWindow
(
this
.
windowId
);
}
...
...
src/vs/platform/windows/electron-main/windows.ts
浏览文件 @
bb55f060
...
...
@@ -58,6 +58,7 @@ export interface IWindowsMainService {
ready
(
initialUserEnv
:
IProcessEnvironment
):
void
;
reload
(
win
:
ICodeWindow
,
cli
?:
ParsedArgs
):
void
;
openWorkspace
(
win
?:
ICodeWindow
):
void
;
createAndOpenWorkspace
(
win
:
ICodeWindow
,
folders
?:
string
[],
path
?:
string
):
void
;
closeWorkspace
(
win
:
ICodeWindow
):
void
;
open
(
openConfig
:
IOpenConfiguration
):
ICodeWindow
[];
openExtensionDevelopmentHostWindow
(
openConfig
:
IOpenConfiguration
):
void
;
...
...
src/vs/platform/windows/electron-main/windowsService.ts
浏览文件 @
bb55f060
...
...
@@ -124,6 +124,16 @@ export class WindowsService implements IWindowsService, IDisposable {
return
TPromise
.
as
(
null
);
}
createAndOpenWorkspace
(
windowId
:
number
,
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
{
const
codeWindow
=
this
.
windowsMainService
.
getWindowById
(
windowId
);
if
(
codeWindow
)
{
this
.
windowsMainService
.
createAndOpenWorkspace
(
codeWindow
,
folders
,
path
);
}
return
TPromise
.
as
(
null
);
}
toggleFullScreen
(
windowId
:
number
):
TPromise
<
void
>
{
const
codeWindow
=
this
.
windowsMainService
.
getWindowById
(
windowId
);
...
...
src/vs/workbench/browser/actions/workspaceActions.ts
浏览文件 @
bb55f060
...
...
@@ -186,8 +186,9 @@ class NewWorkspaceAction extends BaseWorkspacesAction {
}
private
createWorkspace
(
folders
:
URI
[]):
TPromise
<
void
>
{
return
this
.
workspacesService
.
createWorkspace
(
distinct
(
folders
.
map
(
folder
=>
folder
.
toString
(
true
/* encoding */
))))
.
then
(({
configPath
})
=>
this
.
windowsService
.
openWindow
([
configPath
]));
const
workspaceFolders
=
distinct
(
folders
.
map
(
folder
=>
folder
.
toString
(
true
/* encoding */
)));
return
this
.
windowService
.
createAndOpenWorkspace
(
workspaceFolders
);
}
}
...
...
@@ -250,14 +251,9 @@ export class SaveWorkspaceAsAction extends BaseWorkspacesAction {
private
saveFolderWorkspace
(
configPath
:
string
):
TPromise
<
void
>
{
if
(
this
.
handleNotInMultiFolderWorkspaceCase
(
nls
.
localize
(
'
saveNotSupported
'
,
"
To save workspace, window reload is required.
"
)))
{
// Create workspace first
this
.
workspacesService
.
createWorkspace
(
this
.
contextService
.
getWorkspace
().
roots
.
map
(
root
=>
root
.
toString
(
true
/* skip encoding */
)))
.
then
(
workspaceIdentifier
=>
{
// Save the workspace in new location
return
this
.
workspacesService
.
saveWorkspace
(
workspaceIdentifier
,
configPath
)
// Open the saved workspace
.
then
(({
configPath
})
=>
this
.
windowsService
.
openWindow
([
configPath
]));
});
const
workspaceFolders
=
this
.
contextService
.
getWorkspace
().
roots
.
map
(
root
=>
root
.
toString
(
true
/* skip encoding */
));
return
this
.
windowService
.
createAndOpenWorkspace
(
workspaceFolders
,
configPath
);
}
return
TPromise
.
as
(
null
);
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
bb55f060
...
...
@@ -882,6 +882,10 @@ export class TestWindowService implements IWindowService {
return
TPromise
.
as
(
void
0
);
}
createAndOpenWorkspace
(
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
toggleFullScreen
():
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
...
...
@@ -1014,6 +1018,10 @@ export class TestWindowsService implements IWindowsService {
return
TPromise
.
as
(
void
0
);
}
createAndOpenWorkspace
(
windowId
:
number
,
folders
?:
string
[],
path
?:
string
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
toggleFullScreen
(
windowId
:
number
):
TPromise
<
void
>
{
return
TPromise
.
as
(
void
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录