Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d0b3c1a8
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,发现更多精彩内容 >>
提交
d0b3c1a8
编写于
9月 21, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - avoid canHandleResource when restoring backups on startup
上级
2558a72d
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
59 addition
and
24 deletion
+59
-24
src/vs/workbench/common/editor/textEditorModel.ts
src/vs/workbench/common/editor/textEditorModel.ts
+1
-0
src/vs/workbench/parts/backup/common/backupRestorer.ts
src/vs/workbench/parts/backup/common/backupRestorer.ts
+4
-13
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+40
-11
src/vs/workbench/services/editor/common/editorService.ts
src/vs/workbench/services/editor/common/editorService.ts
+9
-0
src/vs/workbench/services/editor/test/browser/editorService.test.ts
...kbench/services/editor/test/browser/editorService.test.ts
+1
-0
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+4
-0
未找到文件。
src/vs/workbench/common/editor/textEditorModel.ts
浏览文件 @
d0b3c1a8
...
...
@@ -74,6 +74,7 @@ export abstract class BaseTextEditorModel extends EditorModel implements ITextEd
protected
createTextEditorModel
(
value
:
ITextBufferFactory
,
resource
?:
URI
,
modeId
?:
string
):
TPromise
<
EditorModel
>
{
const
firstLineText
=
this
.
getFirstLineText
(
value
);
const
mode
=
this
.
getOrCreateMode
(
this
.
modeService
,
modeId
,
firstLineText
);
return
TPromise
.
as
(
this
.
doCreateTextEditorModel
(
value
,
mode
,
resource
));
}
...
...
src/vs/workbench/parts/backup/common/backupRestorer.ts
浏览文件 @
d0b3c1a8
...
...
@@ -7,15 +7,12 @@
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IUntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
ILifecycleService
,
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IUntitledResourceInput
}
from
'
vs/workbench/common/editor
'
;
export
class
BackupRestorer
implements
IWorkbenchContribution
{
...
...
@@ -23,12 +20,9 @@ export class BackupRestorer implements IWorkbenchContribution {
private
static
readonly
UNTITLED_REGEX
=
/Untitled-
\d
+/
;
constructor
(
@
IUntitledEditorService
private
untitledEditorService
:
IUntitledEditorService
,
@
IEditorService
private
editorService
:
IEditorService
,
@
IBackupFileService
private
backupFileService
:
IBackupFileService
,
@
ITextFileService
private
textFileService
:
ITextFileService
,
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
,
@
IFileService
private
fileService
:
IFileService
@
ILifecycleService
private
lifecycleService
:
ILifecycleService
)
{
this
.
restoreBackups
();
}
...
...
@@ -60,12 +54,9 @@ export class BackupRestorer implements IWorkbenchContribution {
const
unresolved
:
URI
[]
=
[];
backups
.
forEach
(
backup
=>
{
if
(
this
.
editorService
.
isOpen
({
resource
:
backup
}))
{
if
(
this
.
fileService
.
canHandleResource
(
backup
))
{
restorePromises
.
push
(
this
.
textFileService
.
models
.
loadOrCreate
(
backup
).
then
(
null
,
()
=>
unresolved
.
push
(
backup
)));
}
else
if
(
backup
.
scheme
===
Schemas
.
untitled
)
{
restorePromises
.
push
(
this
.
untitledEditorService
.
loadOrCreate
({
resource
:
backup
}).
then
(
null
,
()
=>
unresolved
.
push
(
backup
)));
}
const
openedEditor
=
this
.
editorService
.
getOpened
({
resource
:
backup
});
if
(
openedEditor
)
{
restorePromises
.
push
(
openedEditor
.
resolve
().
then
(
null
,
()
=>
unresolved
.
push
(
backup
)));
}
else
{
unresolved
.
push
(
backup
);
}
...
...
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
d0b3c1a8
...
...
@@ -376,6 +376,25 @@ export class EditorService extends Disposable implements EditorServiceImpl {
//#region isOpen()
isOpen
(
editor
:
IEditorInput
|
IResourceInput
|
IUntitledResourceInput
,
group
?:
IEditorGroup
|
GroupIdentifier
):
boolean
{
return
!!
this
.
doGetOpened
(
editor
);
}
//#endregion
//#region getOpend()
getOpened
(
editor
:
IResourceInput
|
IUntitledResourceInput
,
group
?:
IEditorGroup
|
GroupIdentifier
):
IEditorInput
{
return
this
.
doGetOpened
(
editor
);
}
private
doGetOpened
(
editor
:
IEditorInput
|
IResourceInput
|
IUntitledResourceInput
,
group
?:
IEditorGroup
|
GroupIdentifier
):
IEditorInput
{
if
(
!
(
editor
instanceof
EditorInput
))
{
const
resourceInput
=
editor
as
IResourceInput
|
IUntitledResourceInput
;
if
(
!
resourceInput
.
resource
)
{
return
void
0
;
// we need a resource at least
}
}
let
groups
:
IEditorGroup
[]
=
[];
if
(
typeof
group
===
'
number
'
)
{
groups
.
push
(
this
.
editorGroupService
.
getGroup
(
group
));
...
...
@@ -385,22 +404,32 @@ export class EditorService extends Disposable implements EditorServiceImpl {
groups
=
[...
this
.
editorGroupService
.
groups
];
}
return
groups
.
some
(
group
=>
{
// For each editor group
for
(
let
i
=
0
;
i
<
groups
.
length
;
i
++
)
{
const
group
=
groups
[
i
];
// Typed editor
if
(
editor
instanceof
EditorInput
)
{
return
group
.
isOpened
(
editor
);
if
(
group
.
isOpened
(
editor
))
{
return
editor
;
}
const
resourceInput
=
editor
as
IResourceInput
|
IUntitledResourceInput
;
if
(
!
resourceInput
.
resource
)
{
return
false
;
}
return
group
.
editors
.
some
(
editorInGroup
=>
{
// Resource editor
else
{
for
(
let
j
=
0
;
j
<
group
.
editors
.
length
;
j
++
)
{
const
editorInGroup
=
group
.
editors
[
j
];
const
resource
=
toResource
(
editorInGroup
,
{
supportSideBySide
:
true
});
return
resource
&&
resource
.
toString
()
===
resourceInput
.
resource
.
toString
();
});
});
const
resourceInput
=
editor
as
IResourceInput
|
IUntitledResourceInput
;
if
(
resource
.
toString
()
===
resourceInput
.
resource
.
toString
())
{
return
editorInGroup
;
}
}
}
}
return
void
0
;
}
//#endregion
...
...
src/vs/workbench/services/editor/common/editorService.ts
浏览文件 @
d0b3c1a8
...
...
@@ -151,6 +151,15 @@ export interface IEditorService {
*/
isOpen
(
editor
:
IEditorInput
|
IResourceInput
|
IUntitledResourceInput
,
group
?:
IEditorGroup
|
GroupIdentifier
):
boolean
;
/**
* Get the actual opened editor input in any or a specific editor group based on the resource.
*
* Note: An editor can be opened but not actively visible.
*
* @param group optional to specify a group to check for the editor
*/
getOpened
(
editor
:
IResourceInput
|
IUntitledResourceInput
,
group
?:
IEditorGroup
|
GroupIdentifier
):
IEditorInput
;
/**
* Allows to override the opening of editors by installing a handler that will
* be called each time an editor is about to open allowing to override the
...
...
src/vs/workbench/services/editor/test/browser/editorService.test.ts
浏览文件 @
d0b3c1a8
...
...
@@ -104,6 +104,7 @@ suite('Editor service', () => {
assert
.
ok
(
!
service
.
activeTextEditorWidget
);
assert
.
equal
(
service
.
visibleTextEditorWidgets
.
length
,
0
);
assert
.
equal
(
service
.
isOpen
(
input
),
true
);
assert
.
equal
(
service
.
getOpened
({
resource
:
input
.
getResource
()
}),
input
);
assert
.
equal
(
service
.
isOpen
(
input
,
part
.
activeGroup
),
true
);
assert
.
equal
(
activeEditorChangeEventCounter
,
1
);
assert
.
equal
(
visibleEditorChangeEventCounter
,
1
);
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
d0b3c1a8
...
...
@@ -725,6 +725,10 @@ export class TestEditorService implements EditorServiceImpl {
return
false
;
}
getOpened
(
editor
:
IEditorInput
|
IResourceInput
|
IUntitledResourceInput
):
IEditorInput
{
return
void
0
;
}
replaceEditors
(
editors
:
any
,
group
:
any
)
{
return
TPromise
.
as
(
void
0
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录