Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
40d0de32
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,发现更多精彩内容 >>
提交
40d0de32
编写于
11月 18, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use IWindowsService to get window count
Fixes #15642
上级
dc961cbc
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
16 addition
and
106 deletion
+16
-106
src/vs/platform/windows/common/windows.ts
src/vs/platform/windows/common/windows.ts
+1
-0
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
+4
-0
src/vs/workbench/services/backup/common/backup.ts
src/vs/workbench/services/backup/common/backup.ts
+0
-7
src/vs/workbench/services/backup/node/backupFileService.ts
src/vs/workbench/services/backup/node/backupFileService.ts
+0
-36
src/vs/workbench/services/backup/node/backupService.ts
src/vs/workbench/services/backup/node/backupService.ts
+5
-3
src/vs/workbench/services/backup/test/backupFileService.test.ts
.../workbench/services/backup/test/backupFileService.test.ts
+0
-60
未找到文件。
src/vs/platform/windows/common/windows.ts
浏览文件 @
40d0de32
...
@@ -44,6 +44,7 @@ export interface IWindowsService {
...
@@ -44,6 +44,7 @@ export interface IWindowsService {
openNewWindow
():
TPromise
<
void
>
;
openNewWindow
():
TPromise
<
void
>
;
showWindow
(
windowId
:
number
):
TPromise
<
void
>
;
showWindow
(
windowId
:
number
):
TPromise
<
void
>
;
getWindows
():
TPromise
<
{
id
:
number
;
path
:
string
;
title
:
string
;
}[]
>
;
getWindows
():
TPromise
<
{
id
:
number
;
path
:
string
;
title
:
string
;
}[]
>
;
getWindowCount
():
TPromise
<
number
>
;
log
(
severity
:
string
,
...
messages
:
string
[]):
TPromise
<
void
>
;
log
(
severity
:
string
,
...
messages
:
string
[]):
TPromise
<
void
>
;
// TODO@joao: what?
// TODO@joao: what?
closeExtensionHostWindow
(
extensionDevelopmentPath
:
string
):
TPromise
<
void
>
;
closeExtensionHostWindow
(
extensionDevelopmentPath
:
string
):
TPromise
<
void
>
;
...
...
src/vs/platform/windows/common/windowsIpc.ts
浏览文件 @
40d0de32
...
@@ -34,6 +34,7 @@ export interface IWindowsChannel extends IChannel {
...
@@ -34,6 +34,7 @@ export interface IWindowsChannel extends IChannel {
call
(
command
:
'
openNewWindow
'
):
TPromise
<
void
>
;
call
(
command
:
'
openNewWindow
'
):
TPromise
<
void
>
;
call
(
command
:
'
showWindow
'
,
arg
:
number
):
TPromise
<
void
>
;
call
(
command
:
'
showWindow
'
,
arg
:
number
):
TPromise
<
void
>
;
call
(
command
:
'
getWindows
'
):
TPromise
<
{
id
:
number
;
path
:
string
;
title
:
string
;
}[]
>
;
call
(
command
:
'
getWindows
'
):
TPromise
<
{
id
:
number
;
path
:
string
;
title
:
string
;
}[]
>
;
call
(
command
:
'
getWindowCount
'
):
TPromise
<
number
>
;
call
(
command
:
'
log
'
,
arg
:
[
string
,
string
[]]):
TPromise
<
void
>
;
call
(
command
:
'
log
'
,
arg
:
[
string
,
string
[]]):
TPromise
<
void
>
;
call
(
command
:
'
closeExtensionHostWindow
'
,
arg
:
string
):
TPromise
<
void
>
;
call
(
command
:
'
closeExtensionHostWindow
'
,
arg
:
string
):
TPromise
<
void
>
;
call
(
command
:
'
showItemInFolder
'
,
arg
:
string
):
TPromise
<
void
>
;
call
(
command
:
'
showItemInFolder
'
,
arg
:
string
):
TPromise
<
void
>
;
...
@@ -78,6 +79,7 @@ export class WindowsChannel implements IWindowsChannel {
...
@@ -78,6 +79,7 @@ export class WindowsChannel implements IWindowsChannel {
case
'
openNewWindow
'
:
return
this
.
service
.
openNewWindow
();
case
'
openNewWindow
'
:
return
this
.
service
.
openNewWindow
();
case
'
showWindow
'
:
return
this
.
service
.
showWindow
(
arg
);
case
'
showWindow
'
:
return
this
.
service
.
showWindow
(
arg
);
case
'
getWindows
'
:
return
this
.
service
.
getWindows
();
case
'
getWindows
'
:
return
this
.
service
.
getWindows
();
case
'
getWindowCount
'
:
return
this
.
service
.
getWindowCount
();
case
'
log
'
:
return
this
.
service
.
log
(
arg
[
0
],
arg
[
1
]);
case
'
log
'
:
return
this
.
service
.
log
(
arg
[
0
],
arg
[
1
]);
case
'
closeExtensionHostWindow
'
:
return
this
.
service
.
closeExtensionHostWindow
(
arg
);
case
'
closeExtensionHostWindow
'
:
return
this
.
service
.
closeExtensionHostWindow
(
arg
);
case
'
showItemInFolder
'
:
return
this
.
service
.
showItemInFolder
(
arg
);
case
'
showItemInFolder
'
:
return
this
.
service
.
showItemInFolder
(
arg
);
...
@@ -187,6 +189,10 @@ export class WindowsChannelClient implements IWindowsService {
...
@@ -187,6 +189,10 @@ export class WindowsChannelClient implements IWindowsService {
return
this
.
channel
.
call
(
'
getWindows
'
);
return
this
.
channel
.
call
(
'
getWindows
'
);
}
}
getWindowCount
():
TPromise
<
number
>
{
return
this
.
channel
.
call
(
'
getWindowCount
'
);
}
log
(
severity
:
string
,
...
messages
:
string
[]):
TPromise
<
void
>
{
log
(
severity
:
string
,
...
messages
:
string
[]):
TPromise
<
void
>
{
return
this
.
channel
.
call
(
'
log
'
,
[
severity
,
messages
]);
return
this
.
channel
.
call
(
'
log
'
,
[
severity
,
messages
]);
}
}
...
...
src/vs/platform/windows/electron-main/windowsService.ts
浏览文件 @
40d0de32
...
@@ -226,6 +226,10 @@ export class WindowsService implements IWindowsService, IDisposable {
...
@@ -226,6 +226,10 @@ export class WindowsService implements IWindowsService, IDisposable {
return
TPromise
.
as
(
result
);
return
TPromise
.
as
(
result
);
}
}
getWindowCount
():
TPromise
<
number
>
{
return
TPromise
.
as
(
this
.
windowsMainService
.
getWindows
().
length
);
}
log
(
severity
:
string
,
...
messages
:
string
[]):
TPromise
<
void
>
{
log
(
severity
:
string
,
...
messages
:
string
[]):
TPromise
<
void
>
{
console
[
severity
].
apply
(
console
,
...
messages
);
console
[
severity
].
apply
(
console
,
...
messages
);
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
...
...
src/vs/workbench/services/backup/common/backup.ts
浏览文件 @
40d0de32
...
@@ -35,13 +35,6 @@ export interface IBackupService {
...
@@ -35,13 +35,6 @@ export interface IBackupService {
export
interface
IBackupFileService
{
export
interface
IBackupFileService
{
_serviceBrand
:
any
;
_serviceBrand
:
any
;
/**
* Gets the set of active workspace backup paths being tracked for restoration.
*
* @return The set of active workspace backup paths being tracked for restoration.
*/
getWorkspaceBackupPaths
():
TPromise
<
string
[]
>
;
/**
/**
* Gets whether a text file has a backup to restore.
* Gets whether a text file has a backup to restore.
*
*
...
...
src/vs/workbench/services/backup/node/backupFileService.ts
浏览文件 @
40d0de32
...
@@ -9,7 +9,6 @@ import * as path from 'path';
...
@@ -9,7 +9,6 @@ import * as path from 'path';
import
*
as
crypto
from
'
crypto
'
;
import
*
as
crypto
from
'
crypto
'
;
import
pfs
=
require
(
'
vs/base/node/pfs
'
);
import
pfs
=
require
(
'
vs/base/node/pfs
'
);
import
Uri
from
'
vs/base/common/uri
'
;
import
Uri
from
'
vs/base/common/uri
'
;
import
{
IBackupWorkspacesFormat
}
from
'
vs/platform/backup/common/backup
'
;
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
...
@@ -31,16 +30,6 @@ export class BackupFileService implements IBackupFileService {
...
@@ -31,16 +30,6 @@ export class BackupFileService implements IBackupFileService {
this
.
workspacesJsonPath
=
environmentService
.
backupWorkspacesPath
;
this
.
workspacesJsonPath
=
environmentService
.
backupWorkspacesPath
;
}
}
public
getWorkspaceBackupPaths
():
TPromise
<
string
[]
>
{
if
(
this
.
environmentService
.
isExtensionDevelopment
)
{
return
TPromise
.
as
([]);
}
return
this
.
loadWorkspaces
().
then
(
workspacesJsonContent
=>
{
return
workspacesJsonContent
.
folderWorkspaces
;
});
}
public
hasBackup
(
resource
:
Uri
):
TPromise
<
boolean
>
{
public
hasBackup
(
resource
:
Uri
):
TPromise
<
boolean
>
{
const
backupResource
=
this
.
getBackupResource
(
resource
);
const
backupResource
=
this
.
getBackupResource
(
resource
);
if
(
!
backupResource
)
{
if
(
!
backupResource
)
{
...
@@ -103,29 +92,4 @@ export class BackupFileService implements IBackupFileService {
...
@@ -103,29 +92,4 @@ export class BackupFileService implements IBackupFileService {
return
this
.
fileService
.
del
(
Uri
.
file
(
this
.
getWorkspaceBackupDirectory
()));
return
this
.
fileService
.
del
(
Uri
.
file
(
this
.
getWorkspaceBackupDirectory
()));
}
}
private
loadWorkspaces
():
TPromise
<
IBackupWorkspacesFormat
>
{
return
pfs
.
readFile
(
this
.
workspacesJsonPath
,
'
utf8
'
).
then
(
content
=>
{
let
result
:
IBackupWorkspacesFormat
;
try
{
result
=
JSON
.
parse
(
content
.
toString
());
// Ensure folderWorkspaces is a string[]
if
(
result
.
folderWorkspaces
)
{
const
fws
=
result
.
folderWorkspaces
;
if
(
!
Array
.
isArray
(
fws
)
||
fws
.
some
(
f
=>
typeof
f
!==
'
string
'
))
{
result
=
Object
.
create
(
null
);
}
}
}
catch
(
ex
)
{
result
=
Object
.
create
(
null
);
}
if
(
!
result
.
folderWorkspaces
)
{
result
.
folderWorkspaces
=
[];
}
return
result
;
},
()
=>
{
return
{
folderWorkspaces
:
[]
};
});
}
}
}
\ No newline at end of file
src/vs/workbench/services/backup/node/backupService.ts
浏览文件 @
40d0de32
...
@@ -16,6 +16,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
...
@@ -16,6 +16,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IWindowsService
}
from
'
vs/platform/windows/common/windows
'
;
export
class
BackupService
implements
IBackupService
{
export
class
BackupService
implements
IBackupService
{
...
@@ -34,7 +35,8 @@ export class BackupService implements IBackupService {
...
@@ -34,7 +35,8 @@ export class BackupService implements IBackupService {
@
IFileService
private
fileService
:
IFileService
,
@
IFileService
private
fileService
:
IFileService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IWorkspaceContextService
private
contextService
:
IWorkspaceContextService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IWindowsService
private
windowsService
:
IWindowsService
)
{
)
{
this
.
toDispose
=
[];
this
.
toDispose
=
[];
...
@@ -98,12 +100,12 @@ export class BackupService implements IBackupService {
...
@@ -98,12 +100,12 @@ export class BackupService implements IBackupService {
return
TPromise
.
as
({
didBackup
:
false
});
return
TPromise
.
as
({
didBackup
:
false
});
}
}
return
this
.
backupFileService
.
getWorkspaceBackupPaths
().
then
(
workspaceBackupPaths
=>
{
return
this
.
windowsService
.
getWindowCount
().
then
(
windowCount
=>
{
// When quit is requested skip the confirm callback and attempt to backup all workspaces.
// When quit is requested skip the confirm callback and attempt to backup all workspaces.
// When quit is not requested the confirm callback should be shown when the window being
// When quit is not requested the confirm callback should be shown when the window being
// closed is the only VS Code window open, except for on Mac where hot exit is only
// closed is the only VS Code window open, except for on Mac where hot exit is only
// ever activated when quit is requested.
// ever activated when quit is requested.
if
(
!
quitRequested
&&
(
w
orkspaceBackupPaths
.
length
>
1
||
platform
.
isMacintosh
))
{
if
(
!
quitRequested
&&
(
w
indowCount
>
1
||
platform
.
isMacintosh
))
{
return
TPromise
.
as
({
didBackup
:
false
});
return
TPromise
.
as
({
didBackup
:
false
});
}
}
...
...
src/vs/workbench/services/backup/test/backupFileService.test.ts
浏览文件 @
40d0de32
...
@@ -156,64 +156,4 @@ suite('BackupFileService', () => {
...
@@ -156,64 +156,4 @@ suite('BackupFileService', () => {
});
});
});
});
});
});
test
(
'
getWorkspaceBackupPaths should return [] when workspaces.json doesn
\'
t exist
'
,
()
=>
{
fs
.
unlinkSync
(
workspacesJsonPath
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPathsSync should return [] when workspaces.json is not properly formed JSON #1
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
''
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPathsSync should return [] when workspaces.json is not properly formed JSON #1
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{]
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPathsSync should return [] when workspaces.json is not properly formed JSON #1
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
foo
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPathsSync should return [] when folderWorkspaces in workspaces.json is absent
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array #1
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{"folderWorkspaces":{}}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array #2
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{"folderWorkspaces":{"foo": ["bar"]}}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array #3
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{"folderWorkspaces":{"foo": []}}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array #4
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{"folderWorkspaces":{"foo": "bar"}}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array #5
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{"folderWorkspaces":"foo"}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPaths should return [] when folderWorkspaces in workspaces.json is not a string array #6
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{"folderWorkspaces":1}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[]));
});
test
(
'
getWorkspaceBackupPaths should return the contents of folderWorkspaces in workspaces.json
'
,
()
=>
{
fs
.
writeFileSync
(
workspacesJsonPath
,
'
{"folderWorkspaces":["foo", "bar"]}
'
);
service
.
getWorkspaceBackupPaths
().
then
(
paths
=>
assert
.
deepEqual
(
paths
,
[
'
foo
'
,
'
bar
'
]));
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录