Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a76cfdb6
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a76cfdb6
编写于
11月 05, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
strict null checks: grid.ts
fixes #61542
上级
c59c2374
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
22 deletion
+31
-22
src/tsconfig.strictNullChecks.json
src/tsconfig.strictNullChecks.json
+1
-0
src/vs/base/browser/ui/grid/grid.ts
src/vs/base/browser/ui/grid/grid.ts
+29
-21
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+1
-1
未找到文件。
src/tsconfig.strictNullChecks.json
浏览文件 @
a76cfdb6
...
...
@@ -28,6 +28,7 @@
"./vs/base/browser/ui/contextview/contextview.ts"
,
"./vs/base/browser/ui/countBadge/countBadge.ts"
,
"./vs/base/browser/ui/grid/gridview.ts"
,
"./vs/base/browser/ui/grid/grid.ts"
,
"./vs/base/browser/ui/highlightedlabel/highlightedLabel.ts"
,
"./vs/base/browser/ui/iconLabel/iconLabel.ts"
,
"./vs/base/browser/ui/keybindingLabel/keybindingLabel.ts"
,
...
...
src/vs/base/browser/ui/grid/grid.ts
浏览文件 @
a76cfdb6
...
...
@@ -139,10 +139,15 @@ export function getRelativeLocation(rootOrientation: Orientation, location: numb
function
indexInParent
(
element
:
HTMLElement
):
number
{
const
parentElement
=
element
.
parentElement
;
if
(
!
parentElement
)
{
throw
new
Error
(
'
Invalid grid element
'
);
}
let
el
=
parentElement
.
firstElementChild
;
let
index
=
0
;
while
(
el
!==
element
&&
el
!==
parentElement
.
lastElementChild
)
{
while
(
el
!==
element
&&
el
!==
parentElement
.
lastElementChild
&&
el
)
{
el
=
el
.
nextElementSibling
;
index
++
;
}
...
...
@@ -157,12 +162,18 @@ function indexInParent(element: HTMLElement): number {
* This will break as soon as DOM structures of the Splitview or Gridview change.
*/
function
getGridLocation
(
element
:
HTMLElement
):
number
[]
{
if
(
/
\b
monaco-grid-view
\b
/
.
test
(
element
.
parentElement
.
className
))
{
const
parentElement
=
element
.
parentElement
;
if
(
!
parentElement
)
{
throw
new
Error
(
'
Invalid grid element
'
);
}
if
(
/
\b
monaco-grid-view
\b
/
.
test
(
parentElement
.
className
))
{
return
[];
}
const
index
=
indexInParent
(
element
.
parentElement
);
const
ancestor
=
element
.
parentElement
.
parentElement
.
parentElement
.
parentElement
;
const
index
=
indexInParent
(
parentElement
);
const
ancestor
=
parentElement
.
parentElement
!
.
parentElement
!
.
parentElement
!
;
return
[...
getGridLocation
(
ancestor
),
index
];
}
...
...
@@ -193,7 +204,7 @@ export class Grid<T extends IView> implements IDisposable {
get
minimumHeight
():
number
{
return
this
.
gridview
.
minimumHeight
;
}
get
maximumWidth
():
number
{
return
this
.
gridview
.
maximumWidth
;
}
get
maximumHeight
():
number
{
return
this
.
gridview
.
maximumHeight
;
}
get
onDidChange
():
Event
<
{
width
:
number
;
height
:
number
;
}
>
{
return
this
.
gridview
.
onDidChange
;
}
get
onDidChange
():
Event
<
{
width
:
number
;
height
:
number
;
}
|
undefined
>
{
return
this
.
gridview
.
onDidChange
;
}
get
element
():
HTMLElement
{
return
this
.
gridview
.
element
;
}
...
...
@@ -368,7 +379,7 @@ export interface ISerializableView extends IView {
}
export
interface
IViewDeserializer
<
T
extends
ISerializableView
>
{
fromJSON
(
json
:
object
):
T
;
fromJSON
(
json
:
object
|
null
):
T
;
}
interface
InitialLayoutContext
<
T
extends
ISerializableView
>
{
...
...
@@ -379,7 +390,7 @@ interface InitialLayoutContext<T extends ISerializableView> {
export
interface
ISerializedLeafNode
{
type
:
'
leaf
'
;
data
:
object
;
data
:
object
|
null
;
size
:
number
;
}
...
...
@@ -415,18 +426,15 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
throw
new
Error
(
'
Invalid JSON
'
);
}
const
type
=
json
.
type
;
const
data
=
json
.
data
;
if
(
type
===
'
branch
'
)
{
if
(
!
Array
.
isArray
(
data
))
{
if
(
json
.
type
===
'
branch
'
)
{
if
(
!
Array
.
isArray
(
json
.
data
))
{
throw
new
Error
(
'
Invalid JSON:
\'
data
\'
property of branch must be an array.
'
);
}
const
children
:
GridNode
<
T
>
[]
=
[];
let
offset
=
0
;
for
(
const
child
of
data
)
{
for
(
const
child
of
json
.
data
)
{
if
(
typeof
child
.
size
!==
'
number
'
)
{
throw
new
Error
(
'
Invalid JSON:
\'
size
\'
property of node must be a number.
'
);
}
...
...
@@ -441,8 +449,8 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
return
{
children
,
box
};
}
else
if
(
type
===
'
leaf
'
)
{
const
view
=
deserializer
.
fromJSON
(
data
)
as
T
;
}
else
if
(
json
.
type
===
'
leaf
'
)
{
const
view
=
deserializer
.
fromJSON
(
json
.
data
)
as
T
;
return
{
view
,
box
};
}
...
...
@@ -527,13 +535,13 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
const
firstLeaves
=
node
.
children
.
map
(
c
=>
SerializableGrid
.
getFirstLeaf
(
c
));
for
(
let
i
=
1
;
i
<
firstLeaves
.
length
;
i
++
)
{
const
size
=
orientation
===
Orientation
.
VERTICAL
?
firstLeaves
[
i
]
.
box
.
height
:
firstLeaves
[
i
]
.
box
.
width
;
this
.
addView
(
firstLeaves
[
i
].
view
,
size
,
referenceView
,
direction
);
referenceView
=
firstLeaves
[
i
].
view
;
const
size
=
orientation
===
Orientation
.
VERTICAL
?
firstLeaves
[
i
]
!
.
box
.
height
:
firstLeaves
[
i
]
!
.
box
.
width
;
this
.
addView
(
firstLeaves
[
i
]
!
.
view
,
size
,
referenceView
,
direction
);
referenceView
=
firstLeaves
[
i
]
!
.
view
;
}
for
(
let
i
=
0
;
i
<
node
.
children
.
length
;
i
++
)
{
this
.
restoreViews
(
firstLeaves
[
i
].
view
,
orthogonal
(
orientation
),
node
.
children
[
i
]);
this
.
restoreViews
(
firstLeaves
[
i
]
!
.
view
,
orthogonal
(
orientation
),
node
.
children
[
i
]);
}
}
...
...
@@ -611,10 +619,10 @@ function getDimensions(node: ISerializedNode, orientation: Orientation): { width
if
(
orientation
===
Orientation
.
VERTICAL
)
{
const
width
=
node
.
size
||
(
childrenDimensions
.
length
===
0
?
undefined
:
Math
.
max
(...
childrenDimensions
.
map
(
d
=>
d
.
width
||
0
)));
const
height
=
childrenDimensions
.
length
===
0
?
undefined
:
childrenDimensions
.
reduce
((
r
,
d
)
=>
r
+
d
.
height
,
0
);
const
height
=
childrenDimensions
.
length
===
0
?
undefined
:
childrenDimensions
.
reduce
((
r
,
d
)
=>
r
+
(
d
.
height
||
0
)
,
0
);
return
{
width
,
height
};
}
else
{
const
width
=
childrenDimensions
.
length
===
0
?
undefined
:
childrenDimensions
.
reduce
((
r
,
d
)
=>
r
+
d
.
width
,
0
);
const
width
=
childrenDimensions
.
length
===
0
?
undefined
:
childrenDimensions
.
reduce
((
r
,
d
)
=>
r
+
(
d
.
width
||
0
)
,
0
);
const
height
=
node
.
size
||
(
childrenDimensions
.
length
===
0
?
undefined
:
Math
.
max
(...
childrenDimensions
.
map
(
d
=>
d
.
height
||
0
)));
return
{
width
,
height
};
}
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
a76cfdb6
...
...
@@ -877,7 +877,7 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
// Create new
const
groupViews
:
IEditorGroupView
[]
=
[];
const
gridWidget
=
SerializableGrid
.
deserialize
(
serializedGrid
,
{
fromJSON
:
(
serializedEditorGroup
:
ISerializedEditorGroup
)
=>
{
fromJSON
:
(
serializedEditorGroup
:
ISerializedEditorGroup
|
null
)
=>
{
let
groupView
:
IEditorGroupView
;
if
(
reuseGroupViews
.
length
>
0
)
{
groupView
=
reuseGroupViews
.
shift
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录