Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
781950c2
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,发现更多精彩内容 >>
提交
781950c2
编写于
6月 01, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
editors - change whenClosed to use editor interface
上级
705e1ba5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
17 addition
and
18 deletion
+17
-18
src/vs/workbench/electron-browser/window.ts
src/vs/workbench/electron-browser/window.ts
+1
-1
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+11
-11
src/vs/workbench/services/editor/common/editorService.ts
src/vs/workbench/services/editor/common/editorService.ts
+2
-3
src/vs/workbench/services/editor/test/browser/editorService.test.ts
...kbench/services/editor/test/browser/editorService.test.ts
+1
-1
src/vs/workbench/services/host/browser/browserHostService.ts
src/vs/workbench/services/host/browser/browserHostService.ts
+1
-1
src/vs/workbench/test/browser/workbenchTestServices.ts
src/vs/workbench/test/browser/workbenchTestServices.ts
+1
-1
未找到文件。
src/vs/workbench/electron-browser/window.ts
浏览文件 @
781950c2
...
...
@@ -635,7 +635,7 @@ export class NativeWindow extends Disposable {
private
async
trackClosedWaitFiles
(
waitMarkerFile
:
URI
,
resourcesToWaitFor
:
URI
[]):
Promise
<
void
>
{
// Wait for the resources to be closed in the editor...
await
this
.
editorService
.
whenClosed
(
resourcesToWaitFor
,
{
waitForSaved
:
true
});
await
this
.
editorService
.
whenClosed
(
resourcesToWaitFor
.
map
(
resource
=>
({
resource
}))
,
{
waitForSaved
:
true
});
// ...before deleting the wait marker file
await
this
.
fileService
.
del
(
waitMarkerFile
);
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
781950c2
...
...
@@ -1164,8 +1164,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
//#region Editor Tracking
whenClosed
(
resources
:
URI
[],
options
?:
{
waitForSaved
:
boolean
}):
Promise
<
void
>
{
let
remaining
Resources
=
[...
resource
s
];
whenClosed
(
editors
:
IResourceEditorInput
[],
options
?:
{
waitForSaved
:
boolean
}):
Promise
<
void
>
{
let
remaining
Editors
=
[...
editor
s
];
return
new
Promise
(
resolve
=>
{
const
listener
=
this
.
onDidCloseEditor
(
async
event
=>
{
...
...
@@ -1174,8 +1174,8 @@ export class EditorService extends Disposable implements EditorServiceImpl {
// Remove from resources to wait for being closed based on the
// resources from editors that got closed
remaining
Resources
=
remainingResources
.
filter
(
resource
=>
{
if
(
isEqual
(
resource
,
masterResource
)
||
isEqual
(
resource
,
detailsResource
))
{
remaining
Editors
=
remainingEditors
.
filter
(({
resource
})
=>
{
if
(
this
.
uriIdentitiyService
.
extUri
.
isEqual
(
resource
,
masterResource
)
||
this
.
uriIdentitiyService
.
extUri
.
isEqual
(
resource
,
detailsResource
))
{
return
false
;
// remove - the closing editor matches this resource
}
...
...
@@ -1183,15 +1183,15 @@ export class EditorService extends Disposable implements EditorServiceImpl {
});
// All resources to wait for being closed are closed
if
(
remaining
Resource
s
.
length
===
0
)
{
if
(
remaining
Editor
s
.
length
===
0
)
{
if
(
options
?.
waitForSaved
)
{
// If auto save is configured with the default delay (1s) it is possible
// to close the editor while the save still continues in the background. As such
// we have to also check if the
file
s to track for are dirty and if so wait
// we have to also check if the
editor
s to track for are dirty and if so wait
// for them to get saved.
const
dirty
Files
=
resources
.
filter
(
resource
=>
this
.
workingCopyService
.
isDirty
(
resource
)
);
if
(
dirty
Fil
es
.
length
>
0
)
{
await
Promise
.
all
(
dirty
Files
.
map
(
async
dirtyFile
=>
await
this
.
whenSaved
(
dirtyFil
e
)));
const
dirty
Resources
=
editors
.
filter
(({
resource
})
=>
this
.
workingCopyService
.
isDirty
(
resource
)).
map
(({
resource
})
=>
resource
);
if
(
dirty
Resourc
es
.
length
>
0
)
{
await
Promise
.
all
(
dirty
Resources
.
map
(
async
resource
=>
await
this
.
whenSaved
(
resourc
e
)));
}
}
...
...
@@ -1211,7 +1211,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
// Otherwise resolve promise when resource is saved
const
listener
=
this
.
workingCopyService
.
onDidChangeDirty
(
workingCopy
=>
{
if
(
!
workingCopy
.
isDirty
()
&&
isEqual
(
resource
,
workingCopy
.
resource
))
{
if
(
!
workingCopy
.
isDirty
()
&&
this
.
uriIdentitiyService
.
extUri
.
isEqual
(
resource
,
workingCopy
.
resource
))
{
listener
.
dispose
();
resolve
();
...
...
@@ -1340,7 +1340,7 @@ export class DelegatingEditorService implements IEditorService {
registerCustomEditorViewTypesHandler
(
source
:
string
,
handler
:
ICustomEditorViewTypesHandler
):
IDisposable
{
return
this
.
editorService
.
registerCustomEditorViewTypesHandler
(
source
,
handler
);
}
whenClosed
(
resources
:
URI
[]):
Promise
<
void
>
{
return
this
.
editorService
.
whenClosed
(
resource
s
);
}
whenClosed
(
editors
:
IResourceEditorInput
[]):
Promise
<
void
>
{
return
this
.
editorService
.
whenClosed
(
editor
s
);
}
//#endregion
}
...
...
src/vs/workbench/services/editor/common/editorService.ts
浏览文件 @
781950c2
...
...
@@ -289,12 +289,11 @@ export interface IEditorService {
revertAll
(
options
?:
IRevertAllEditorsOptions
):
Promise
<
boolean
>
;
/**
* Track the provided list of resources for being opened as editors
* and resolve once all have been closed.
* Track the provided editors until all have been closed.
*
* @param options use `waitForSaved: true` to wait for the resources
* being saved. If auto-save is enabled, it may be possible to close
* an editor while the save continues in the background.
*/
whenClosed
(
resources
:
URI
[],
options
?:
{
waitForSaved
:
boolean
}):
Promise
<
void
>
;
whenClosed
(
editors
:
IResourceEditorInput
[],
options
?:
{
waitForSaved
:
boolean
}):
Promise
<
void
>
;
}
src/vs/workbench/services/editor/test/browser/editorService.test.ts
浏览文件 @
781950c2
...
...
@@ -1084,7 +1084,7 @@ suite('EditorService', () => {
const
editor
=
await
service
.
openEditor
(
input1
,
{
pinned
:
true
});
await
service
.
openEditor
(
input2
,
{
pinned
:
true
});
const
whenClosed
=
service
.
whenClosed
([
input1
.
resource
,
input2
.
resource
]);
const
whenClosed
=
service
.
whenClosed
([
input1
,
input2
]);
editor
?.
group
?.
closeAllEditors
();
...
...
src/vs/workbench/services/host/browser/browserHostService.ts
浏览文件 @
781950c2
...
...
@@ -224,7 +224,7 @@ export class BrowserHostService extends Disposable implements IHostService {
(
async
()
=>
{
// Wait for the resources to be closed in the editor...
await
this
.
editorService
.
whenClosed
(
fileOpenables
.
map
(
openable
=>
openable
.
fileUri
),
{
waitForSaved
:
true
});
await
this
.
editorService
.
whenClosed
(
fileOpenables
.
map
(
openable
=>
({
resource
:
openable
.
fileUri
})
),
{
waitForSaved
:
true
});
// ...before deleting the wait marker file
await
this
.
fileService
.
del
(
waitMarkerFileURI
);
...
...
src/vs/workbench/test/browser/workbenchTestServices.ts
浏览文件 @
781950c2
...
...
@@ -676,7 +676,7 @@ export class TestEditorService implements EditorServiceImpl {
saveAll
(
options
?:
ISaveEditorsOptions
):
Promise
<
boolean
>
{
throw
new
Error
(
'
Method not implemented.
'
);
}
revert
(
editors
:
IEditorIdentifier
[],
options
?:
IRevertOptions
):
Promise
<
boolean
>
{
throw
new
Error
(
'
Method not implemented.
'
);
}
revertAll
(
options
?:
IRevertAllEditorsOptions
):
Promise
<
boolean
>
{
throw
new
Error
(
'
Method not implemented.
'
);
}
whenClosed
(
resources
:
URI
[],
options
?:
{
waitForSaved
:
boolean
}):
Promise
<
void
>
{
throw
new
Error
(
'
Method not implemented.
'
);
}
whenClosed
(
editors
:
IResourceEditorInput
[],
options
?:
{
waitForSaved
:
boolean
}):
Promise
<
void
>
{
throw
new
Error
(
'
Method not implemented.
'
);
}
}
export
class
TestFileService
implements
IFileService
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录