Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
600c7db7
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,发现更多精彩内容 >>
提交
600c7db7
编写于
7月 29, 2019
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid: do not layout views until deserialization is complete
上级
c429b412
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
35 addition
and
11 deletion
+35
-11
src/vs/base/browser/ui/grid/grid.ts
src/vs/base/browser/ui/grid/grid.ts
+6
-1
src/vs/base/browser/ui/grid/gridview.ts
src/vs/base/browser/ui/grid/gridview.ts
+29
-10
未找到文件。
src/vs/base/browser/ui/grid/grid.ts
浏览文件 @
600c7db7
...
@@ -7,7 +7,7 @@ import 'vs/css!./gridview';
...
@@ -7,7 +7,7 @@ import 'vs/css!./gridview';
import
{
Orientation
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
Orientation
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
tail2
as
tail
,
equals
}
from
'
vs/base/common/arrays
'
;
import
{
tail2
as
tail
,
equals
}
from
'
vs/base/common/arrays
'
;
import
{
orthogonal
,
IView
as
IGridViewView
,
GridView
,
Sizing
as
GridViewSizing
,
Box
,
IGridViewStyles
,
IViewSize
}
from
'
./gridview
'
;
import
{
orthogonal
,
IView
as
IGridViewView
,
GridView
,
Sizing
as
GridViewSizing
,
Box
,
IGridViewStyles
,
IViewSize
,
ILayoutController
,
LayoutController
}
from
'
./gridview
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
InvisibleSizing
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
import
{
InvisibleSizing
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
...
@@ -197,6 +197,7 @@ export interface IGridOptions {
...
@@ -197,6 +197,7 @@ export interface IGridOptions {
readonly
styles
?:
IGridStyles
;
readonly
styles
?:
IGridStyles
;
readonly
proportionalLayout
?:
boolean
;
readonly
proportionalLayout
?:
boolean
;
readonly
firstViewVisibleCachedSize
?:
number
;
readonly
firstViewVisibleCachedSize
?:
number
;
readonly
layoutController
?:
ILayoutController
;
}
}
export
class
Grid
<
T
extends
IView
=
IView
>
extends
Disposable
{
export
class
Grid
<
T
extends
IView
=
IView
>
extends
Disposable
{
...
@@ -534,6 +535,9 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
...
@@ -534,6 +535,9 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
throw
new
Error
(
'
Invalid serialized state, first leaf not found
'
);
throw
new
Error
(
'
Invalid serialized state, first leaf not found
'
);
}
}
const
layoutController
=
new
LayoutController
(
false
);
options
=
{
...
options
,
layoutController
};
if
(
typeof
firstLeaf
.
cachedVisibleSize
===
'
number
'
)
{
if
(
typeof
firstLeaf
.
cachedVisibleSize
===
'
number
'
)
{
options
=
{
...
options
,
firstViewVisibleCachedSize
:
firstLeaf
.
cachedVisibleSize
};
options
=
{
...
options
,
firstViewVisibleCachedSize
:
firstLeaf
.
cachedVisibleSize
};
}
}
...
@@ -543,6 +547,7 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
...
@@ -543,6 +547,7 @@ export class SerializableGrid<T extends ISerializableView> extends Grid<T> {
result
.
restoreViews
(
firstLeaf
.
view
,
orientation
,
root
);
result
.
restoreViews
(
firstLeaf
.
view
,
orientation
,
root
);
result
.
initialLayoutContext
=
{
width
,
height
,
root
};
result
.
initialLayoutContext
=
{
width
,
height
,
root
};
layoutController
.
isLayoutEnabled
=
true
;
return
result
;
return
result
;
}
}
...
...
src/vs/base/browser/ui/grid/gridview.ts
浏览文件 @
600c7db7
...
@@ -67,9 +67,18 @@ const defaultStyles: IGridViewStyles = {
...
@@ -67,9 +67,18 @@ const defaultStyles: IGridViewStyles = {
separatorBorder
:
Color
.
transparent
separatorBorder
:
Color
.
transparent
};
};
export
interface
ILayoutController
{
readonly
isLayoutEnabled
:
boolean
;
}
export
class
LayoutController
implements
ILayoutController
{
constructor
(
public
isLayoutEnabled
:
boolean
)
{
}
}
export
interface
IGridViewOptions
{
export
interface
IGridViewOptions
{
styles
?:
IGridViewStyles
;
readonly
styles
?:
IGridViewStyles
;
proportionalLayout
?:
boolean
;
// default true
readonly
proportionalLayout
?:
boolean
;
// default true
readonly
layoutController
?:
ILayoutController
;
}
}
class
BranchNode
implements
ISplitView
,
IDisposable
{
class
BranchNode
implements
ISplitView
,
IDisposable
{
...
@@ -466,7 +475,8 @@ class LeafNode implements ISplitView, IDisposable {
...
@@ -466,7 +475,8 @@ class LeafNode implements ISplitView, IDisposable {
constructor
(
constructor
(
readonly
view
:
IView
,
readonly
view
:
IView
,
readonly
orientation
:
Orientation
,
readonly
orientation
:
Orientation
,
orthogonalSize
:
number
=
0
readonly
layoutController
:
ILayoutController
,
orthogonalSize
:
number
)
{
)
{
this
.
_orthogonalSize
=
orthogonalSize
;
this
.
_orthogonalSize
=
orthogonalSize
;
...
@@ -536,7 +546,10 @@ class LeafNode implements ISplitView, IDisposable {
...
@@ -536,7 +546,10 @@ class LeafNode implements ISplitView, IDisposable {
layout
(
size
:
number
):
void
{
layout
(
size
:
number
):
void
{
this
.
_size
=
size
;
this
.
_size
=
size
;
return
this
.
view
.
layout
(
this
.
width
,
this
.
height
,
orthogonal
(
this
.
orientation
));
if
(
this
.
layoutController
.
isLayoutEnabled
)
{
this
.
view
.
layout
(
this
.
width
,
this
.
height
,
orthogonal
(
this
.
orientation
));
}
}
}
setVisible
(
visible
:
boolean
):
void
{
setVisible
(
visible
:
boolean
):
void
{
...
@@ -553,7 +566,10 @@ class LeafNode implements ISplitView, IDisposable {
...
@@ -553,7 +566,10 @@ class LeafNode implements ISplitView, IDisposable {
orthogonalLayout
(
size
:
number
):
void
{
orthogonalLayout
(
size
:
number
):
void
{
this
.
_orthogonalSize
=
size
;
this
.
_orthogonalSize
=
size
;
return
this
.
view
.
layout
(
this
.
width
,
this
.
height
,
orthogonal
(
this
.
orientation
));
if
(
this
.
layoutController
.
isLayoutEnabled
)
{
this
.
view
.
layout
(
this
.
width
,
this
.
height
,
orthogonal
(
this
.
orientation
));
}
}
}
dispose
():
void
{
}
dispose
():
void
{
}
...
@@ -584,7 +600,7 @@ function flipNode<T extends Node>(node: T, size: number, orthogonalSize: number)
...
@@ -584,7 +600,7 @@ function flipNode<T extends Node>(node: T, size: number, orthogonalSize: number)
return
result
as
T
;
return
result
as
T
;
}
else
{
}
else
{
return
new
LeafNode
((
node
as
LeafNode
).
view
,
orthogonal
(
node
.
orientation
),
orthogonalSize
)
as
T
;
return
new
LeafNode
((
node
as
LeafNode
).
view
,
orthogonal
(
node
.
orientation
),
(
node
as
LeafNode
).
layoutController
,
orthogonalSize
)
as
T
;
}
}
}
}
...
@@ -644,11 +660,14 @@ export class GridView implements IDisposable {
...
@@ -644,11 +660,14 @@ export class GridView implements IDisposable {
private
_onDidChange
=
new
Relay
<
IViewSize
|
undefined
>
();
private
_onDidChange
=
new
Relay
<
IViewSize
|
undefined
>
();
readonly
onDidChange
=
this
.
_onDidChange
.
event
;
readonly
onDidChange
=
this
.
_onDidChange
.
event
;
private
layoutController
:
LayoutController
;
constructor
(
options
:
IGridViewOptions
=
{})
{
constructor
(
options
:
IGridViewOptions
=
{})
{
this
.
element
=
$
(
'
.monaco-grid-view
'
);
this
.
element
=
$
(
'
.monaco-grid-view
'
);
this
.
styles
=
options
.
styles
||
defaultStyles
;
this
.
styles
=
options
.
styles
||
defaultStyles
;
this
.
proportionalLayout
=
typeof
options
.
proportionalLayout
!==
'
undefined
'
?
!!
options
.
proportionalLayout
:
true
;
this
.
proportionalLayout
=
typeof
options
.
proportionalLayout
!==
'
undefined
'
?
!!
options
.
proportionalLayout
:
true
;
this
.
root
=
new
BranchNode
(
Orientation
.
VERTICAL
,
this
.
styles
,
this
.
proportionalLayout
);
this
.
root
=
new
BranchNode
(
Orientation
.
VERTICAL
,
this
.
styles
,
this
.
proportionalLayout
);
this
.
layoutController
=
options
.
layoutController
||
new
LayoutController
(
true
);
}
}
style
(
styles
:
IGridViewStyles
):
void
{
style
(
styles
:
IGridViewStyles
):
void
{
...
@@ -670,7 +689,7 @@ export class GridView implements IDisposable {
...
@@ -670,7 +689,7 @@ export class GridView implements IDisposable {
const
[
pathToParent
,
parent
]
=
this
.
getNode
(
rest
);
const
[
pathToParent
,
parent
]
=
this
.
getNode
(
rest
);
if
(
parent
instanceof
BranchNode
)
{
if
(
parent
instanceof
BranchNode
)
{
const
node
=
new
LeafNode
(
view
,
orthogonal
(
parent
.
orientation
),
parent
.
orthogonalSize
);
const
node
=
new
LeafNode
(
view
,
orthogonal
(
parent
.
orientation
),
this
.
layoutController
,
parent
.
orthogonalSize
);
parent
.
addChild
(
node
,
size
,
index
);
parent
.
addChild
(
node
,
size
,
index
);
}
else
{
}
else
{
...
@@ -690,14 +709,14 @@ export class GridView implements IDisposable {
...
@@ -690,14 +709,14 @@ export class GridView implements IDisposable {
grandParent
.
addChild
(
newParent
,
parent
.
size
,
parentIndex
);
grandParent
.
addChild
(
newParent
,
parent
.
size
,
parentIndex
);
newParent
.
orthogonalLayout
(
parent
.
orthogonalSize
);
newParent
.
orthogonalLayout
(
parent
.
orthogonalSize
);
const
newSibling
=
new
LeafNode
(
parent
.
view
,
grandParent
.
orientation
,
parent
.
size
);
const
newSibling
=
new
LeafNode
(
parent
.
view
,
grandParent
.
orientation
,
this
.
layoutController
,
parent
.
size
);
newParent
.
addChild
(
newSibling
,
newSiblingSize
,
0
);
newParent
.
addChild
(
newSibling
,
newSiblingSize
,
0
);
if
(
typeof
size
!==
'
number
'
&&
size
.
type
===
'
split
'
)
{
if
(
typeof
size
!==
'
number
'
&&
size
.
type
===
'
split
'
)
{
size
=
Sizing
.
Split
(
0
);
size
=
Sizing
.
Split
(
0
);
}
}
const
node
=
new
LeafNode
(
view
,
grandParent
.
orientation
,
parent
.
size
);
const
node
=
new
LeafNode
(
view
,
grandParent
.
orientation
,
this
.
layoutController
,
parent
.
size
);
newParent
.
addChild
(
node
,
size
,
index
);
newParent
.
addChild
(
node
,
size
,
index
);
}
}
}
}
...
@@ -759,7 +778,7 @@ export class GridView implements IDisposable {
...
@@ -759,7 +778,7 @@ export class GridView implements IDisposable {
grandParent
.
addChild
(
child
,
child
.
size
,
parentIndex
+
i
);
grandParent
.
addChild
(
child
,
child
.
size
,
parentIndex
+
i
);
}
}
}
else
{
}
else
{
const
newSibling
=
new
LeafNode
(
sibling
.
view
,
orthogonal
(
sibling
.
orientation
),
sibling
.
size
);
const
newSibling
=
new
LeafNode
(
sibling
.
view
,
orthogonal
(
sibling
.
orientation
),
this
.
layoutController
,
sibling
.
size
);
grandParent
.
addChild
(
newSibling
,
sibling
.
orthogonalSize
,
parentIndex
);
grandParent
.
addChild
(
newSibling
,
sibling
.
orthogonalSize
,
parentIndex
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录