Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
afda5a25
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,发现更多精彩内容 >>
提交
afda5a25
编写于
5月 12, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add a way to validate stacks model while running
上级
2a19987c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
31 addition
and
5 deletion
+31
-5
src/vs/workbench/browser/parts/editor/editor.contribution.ts
src/vs/workbench/browser/parts/editor/editor.contribution.ts
+11
-0
src/vs/workbench/common/editor/editorStacksModel.ts
src/vs/workbench/common/editor/editorStacksModel.ts
+20
-5
未找到文件。
src/vs/workbench/browser/parts/editor/editor.contribution.ts
浏览文件 @
afda5a25
...
...
@@ -29,6 +29,7 @@ import {Scope, IActionBarRegistry, Extensions as ActionBarExtensions} from 'vs/w
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
EditorStacksModel
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
// Register String Editor
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
registerEditor
(
...
...
@@ -188,3 +189,13 @@ KeybindingsRegistry.registerCommandDesc({
when
:
undefined
,
primary
:
undefined
});
KeybindingsRegistry
.
registerCommandDesc
({
id
:
'
_workbench.validateStacksModel
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
0
),
handler
(
accessor
:
ServicesAccessor
)
{
(
<
EditorStacksModel
>
accessor
.
get
(
IWorkbenchEditorService
).
getStacksModel
()).
validate
();
},
when
:
undefined
,
primary
:
undefined
});
\ No newline at end of file
src/vs/workbench/common/editor/editorStacksModel.ts
浏览文件 @
afda5a25
...
...
@@ -759,6 +759,12 @@ export class EditorStacksModel implements IEditorStacksModel {
}
private
save
():
void
{
const
serialized
=
this
.
serialize
();
this
.
storageService
.
store
(
EditorStacksModel
.
STORAGE_KEY
,
JSON
.
stringify
(
serialized
),
StorageScope
.
WORKSPACE
);
}
private
serialize
():
ISerializedEditorStacksModel
{
let
activeIndex
=
this
.
indexOf
(
this
.
_activeGroup
);
let
activeIsEmptyGroup
=
false
;
...
...
@@ -791,12 +797,10 @@ export class EditorStacksModel implements IEditorStacksModel {
serializableActiveIndex
=
activeIndex
;
// active group is not empty and can be serialized
}
const
serialized
:
ISerializedEditorStacksModel
=
{
return
{
groups
:
serializedGroups
,
active
:
serializableActiveIndex
};
this
.
storageService
.
store
(
EditorStacksModel
.
STORAGE_KEY
,
JSON
.
stringify
(
serialized
),
StorageScope
.
WORKSPACE
);
}
private
fireEvent
(
emitter
:
Emitter
<
EditorGroup
>
,
group
:
EditorGroup
):
void
{
...
...
@@ -822,7 +826,7 @@ export class EditorStacksModel implements IEditorStacksModel {
const
serialized
:
ISerializedEditorStacksModel
=
JSON
.
parse
(
modelRaw
);
// TODO@stacks remove this once stacks are stable; prevent bad stored state
const
invalidId
=
this
.
v
alidate
(
serialized
);
const
invalidId
=
this
.
doV
alidate
(
serialized
);
if
(
invalidId
)
{
console
.
warn
(
`Ignoring invalid stacks model (Error code:
${
invalidId
}
):
${
JSON
.
stringify
(
serialized
)}
`
);
console
.
warn
(
serialized
);
...
...
@@ -835,7 +839,7 @@ export class EditorStacksModel implements IEditorStacksModel {
}
}
private
v
alidate
(
serialized
:
ISerializedEditorStacksModel
):
number
{
private
doV
alidate
(
serialized
:
ISerializedEditorStacksModel
):
number
{
if
(
!
serialized
.
groups
.
length
&&
typeof
serialized
.
active
===
'
number
'
)
{
return
1
;
// Invalid active (we have no groups, but an active one)
}
...
...
@@ -887,6 +891,17 @@ export class EditorStacksModel implements IEditorStacksModel {
dispose
(
this
.
toDispose
);
}
public
validate
():
void
{
const
serialized
=
this
.
serialize
();
const
invalidId
=
this
.
doValidate
(
serialized
);
if
(
invalidId
)
{
console
.
warn
(
`Ignoring invalid stacks model (Error code:
${
invalidId
}
):
${
JSON
.
stringify
(
serialized
)}
`
);
console
.
warn
(
serialized
);
}
else
{
console
.
log
(
'
Stacks Model OK!
'
);
}
}
public
toString
():
string
{
this
.
ensureLoaded
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录