Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
3b974dec
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,发现更多精彩内容 >>
提交
3b974dec
编写于
6月 15, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
address feedback
上级
f19ae63f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
83 addition
and
51 deletion
+83
-51
src/vs/base/browser/ui/grid/grid.ts
src/vs/base/browser/ui/grid/grid.ts
+1
-1
src/vs/base/browser/ui/grid/gridview.ts
src/vs/base/browser/ui/grid/gridview.ts
+3
-8
src/vs/base/test/browser/ui/grid/grid.test.ts
src/vs/base/test/browser/ui/grid/grid.test.ts
+72
-39
src/vs/base/test/browser/ui/grid/gridview.test.ts
src/vs/base/test/browser/ui/grid/gridview.test.ts
+7
-3
未找到文件。
src/vs/base/browser/ui/grid/grid.ts
浏览文件 @
3b974dec
...
...
@@ -199,7 +199,7 @@ export class Grid<T extends IView> implements IDisposable {
public
sashResetSizing
:
Sizing
=
Sizing
.
Distribute
;
get
container
():
HTMLElement
{
return
this
.
gridview
.
container
;
return
this
.
gridview
.
element
;
}
constructor
(
view
:
T
,
options
:
IGridOptions
=
{})
{
...
...
src/vs/base/browser/ui/grid/gridview.ts
浏览文件 @
3b974dec
...
...
@@ -10,7 +10,7 @@ import { Event, anyEvent, Emitter, mapEvent, Relay } from 'vs/base/common/event'
import
{
Orientation
,
Sash
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
SplitView
,
IView
as
ISplitView
,
Sizing
,
ISplitViewStyles
}
from
'
vs/base/browser/ui/splitview/splitview
'
;
import
{
empty
as
EmptyDisposable
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
$
,
append
}
from
'
vs/base/browser/dom
'
;
import
{
$
}
from
'
vs/base/browser/dom
'
;
import
{
tail2
as
tail
}
from
'
vs/base/common/arrays
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
...
...
@@ -418,7 +418,7 @@ function flipNode<T extends Node>(node: T, size: number, orthogonalSize: number)
export
class
GridView
implements
IDisposable
{
private
element
:
HTMLElement
;
readonly
element
:
HTMLElement
;
private
styles
:
IGridViewStyles
;
private
_root
:
BranchNode
;
...
...
@@ -483,11 +483,8 @@ export class GridView implements IDisposable {
return
this
.
root
.
maximumHeight
;
}
readonly
container
:
HTMLElement
;
constructor
(
options
:
IGridViewOptions
=
{})
{
this
.
container
=
$
(
'
.
'
);
this
.
element
=
append
(
this
.
container
,
$
(
'
.monaco-grid-view
'
));
this
.
element
=
$
(
'
.monaco-grid-view
'
);
this
.
styles
=
options
.
styles
||
defaultStyles
;
this
.
root
=
new
BranchNode
(
Orientation
.
VERTICAL
,
this
.
styles
);
}
...
...
@@ -760,7 +757,5 @@ export class GridView implements IDisposable {
if
(
this
.
element
&&
this
.
element
.
parentElement
)
{
this
.
element
.
parentElement
.
removeChild
(
this
.
element
);
}
this
.
element
=
null
;
}
}
src/vs/base/test/browser/ui/grid/grid.test.ts
浏览文件 @
3b974dec
...
...
@@ -4,20 +4,23 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
Direction
,
Grid
,
getRelativeLocation
,
Orientation
,
SerializableGrid
,
ISerializableView
,
IViewDeserializer
,
GridNode
,
Sizing
,
isGridBranchNode
,
sanitizeGridNodeDescriptor
,
GridNodeDescriptor
,
createSerialized
Grid
}
from
'
vs/base/browser/ui/grid/grid
'
;
import
{
Direction
,
getRelativeLocation
,
Orientation
,
SerializableGrid
,
ISerializableView
,
IViewDeserializer
,
GridNode
,
Sizing
,
isGridBranchNode
,
sanitizeGridNodeDescriptor
,
GridNodeDescriptor
,
createSerializedGrid
,
Grid
}
from
'
vs/base/browser/ui/grid/grid
'
;
import
{
TestView
,
nodesToArrays
}
from
'
./util
'
;
import
{
deepClone
}
from
'
vs/base/common/objects
'
;
function
setupGrid
(
view
:
TestView
):
Grid
<
TestView
>
{
const
grid
=
new
Grid
(
view
);
grid
.
container
.
style
.
position
=
'
absolute
'
;
grid
.
container
.
style
.
width
=
`
${
800
}
px`
;
grid
.
container
.
style
.
height
=
`
${
600
}
px`
;
suite
(
'
Grid
'
,
function
()
{
let
container
:
HTMLElement
;
return
grid
;
}
setup
(
function
()
{
container
=
document
.
createElement
(
'
div
'
);
container
.
style
.
position
=
'
absolute
'
;
container
.
style
.
width
=
`
${
800
}
px`
;
container
.
style
.
height
=
`
${
600
}
px`
;
});
suite
(
'
Grid
'
,
function
()
{
teardown
(
function
()
{
container
=
null
;
});
test
(
'
getRelativeLocation
'
,
function
()
{
assert
.
deepEqual
(
getRelativeLocation
(
Orientation
.
VERTICAL
,
[
0
],
Direction
.
Up
),
[
0
]);
...
...
@@ -53,7 +56,8 @@ suite('Grid', function () {
test
(
'
empty
'
,
function
()
{
const
view1
=
new
TestView
(
100
,
Number
.
MAX_VALUE
,
100
,
Number
.
MAX_VALUE
);
const
gridview
=
setupGrid
(
view1
);
const
gridview
=
new
Grid
(
view1
);
container
.
appendChild
(
gridview
.
container
);
gridview
.
layout
(
800
,
600
);
assert
.
deepEqual
(
view1
.
size
,
[
800
,
600
]);
...
...
@@ -61,7 +65,8 @@ suite('Grid', function () {
test
(
'
two views vertically
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
assert
.
deepEqual
(
view1
.
size
,
[
800
,
600
]);
...
...
@@ -73,7 +78,9 @@ suite('Grid', function () {
test
(
'
two views horizontally
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
assert
.
deepEqual
(
view1
.
size
,
[
800
,
600
]);
...
...
@@ -85,7 +92,9 @@ suite('Grid', function () {
test
(
'
simple layout
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
assert
.
deepEqual
(
view1
.
size
,
[
800
,
600
]);
...
...
@@ -118,7 +127,8 @@ suite('Grid', function () {
test
(
'
another simple layout with automatic size distribution
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
assert
.
deepEqual
(
view1
.
size
,
[
800
,
600
]);
...
...
@@ -161,7 +171,9 @@ suite('Grid', function () {
test
(
'
another simple layout with split size distribution
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
assert
.
deepEqual
(
view1
.
size
,
[
800
,
600
]);
...
...
@@ -203,7 +215,8 @@ suite('Grid', function () {
test
(
'
3/2 layout with split
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
assert
.
deepEqual
(
view1
.
size
,
[
800
,
600
]);
...
...
@@ -237,7 +250,8 @@ suite('Grid', function () {
test
(
'
sizing should be correct after branch demotion #50564
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -262,7 +276,8 @@ suite('Grid', function () {
test
(
'
sizing should be correct after branch demotion #50675
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -287,7 +302,8 @@ suite('Grid', function () {
test
(
'
getNeighborViews should work on single view layout
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -304,7 +320,8 @@ suite('Grid', function () {
test
(
'
getNeighborViews should work on simple layout
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -347,7 +364,8 @@ suite('Grid', function () {
test
(
'
getNeighborViews should work on a complex layout
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -387,7 +405,8 @@ suite('Grid', function () {
test
(
'
getNeighborViews should work on another simple layout
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -408,7 +427,8 @@ suite('Grid', function () {
test
(
'
getNeighborViews should only return immediate neighbors
'
,
function
()
{
const
view1
=
new
TestView
(
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupGrid
(
view1
);
const
grid
=
new
Grid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -465,19 +485,25 @@ function nodesToNames(node: GridNode<TestSerializableView>): any {
}
}
function
setupSerializedGrid
(
view
:
TestSerializableView
):
SerializableGrid
<
TestSerializableView
>
{
const
grid
=
new
SerializableGrid
(
view
);
grid
.
container
.
style
.
position
=
'
absolute
'
;
grid
.
container
.
style
.
width
=
`
${
800
}
px`
;
grid
.
container
.
style
.
height
=
`
${
600
}
px`
;
suite
(
'
SerializableGrid
'
,
function
()
{
return
grid
;
}
let
container
:
HTMLElement
;
setup
(
function
()
{
container
=
document
.
createElement
(
'
div
'
);
container
.
style
.
position
=
'
absolute
'
;
container
.
style
.
width
=
`
${
800
}
px`
;
container
.
style
.
height
=
`
${
600
}
px`
;
});
teardown
(
function
()
{
container
=
null
;
});
suite
(
'
SerializableGrid
'
,
function
()
{
test
(
'
serialize empty
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
assert
.
deepEqual
(
grid
.
serialize
(),
{
...
...
@@ -502,7 +528,8 @@ suite('SerializableGrid', function () {
test
(
'
serialize simple layout
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
const
view2
=
new
TestSerializableView
(
'
view2
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
...
...
@@ -555,7 +582,8 @@ suite('SerializableGrid', function () {
test
(
'
deserialize empty
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
const
json
=
grid
.
serialize
();
...
...
@@ -570,7 +598,8 @@ suite('SerializableGrid', function () {
test
(
'
deserialize simple layout
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -617,7 +646,8 @@ suite('SerializableGrid', function () {
test
(
'
deserialize simple layout with scaling
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -655,7 +685,8 @@ suite('SerializableGrid', function () {
test
(
'
deserialize 4 view layout (ben issue #2)
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
const
view2
=
new
TestSerializableView
(
'
view2
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
...
...
@@ -688,7 +719,8 @@ suite('SerializableGrid', function () {
test
(
'
deserialize 2 view layout (ben issue #3)
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
@@ -712,7 +744,8 @@ suite('SerializableGrid', function () {
test
(
'
deserialize simple view layout #50609
'
,
function
()
{
const
view1
=
new
TestSerializableView
(
'
view1
'
,
50
,
Number
.
MAX_VALUE
,
50
,
Number
.
MAX_VALUE
);
const
grid
=
setupSerializedGrid
(
view1
);
const
grid
=
new
SerializableGrid
(
view1
);
container
.
appendChild
(
grid
.
container
);
grid
.
layout
(
800
,
600
);
...
...
src/vs/base/test/browser/ui/grid/gridview.test.ts
浏览文件 @
3b974dec
...
...
@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
{
$
}
from
'
vs/base/browser/dom
'
;
import
{
GridView
,
IView
,
Sizing
}
from
'
vs/base/browser/ui/grid/gridview
'
;
import
{
nodesToArrays
,
TestView
}
from
'
./util
'
;
...
...
@@ -12,9 +13,12 @@ suite('Gridview', function () {
setup
(
function
()
{
gridview
=
new
GridView
();
gridview
.
container
.
style
.
position
=
'
absolute
'
;
gridview
.
container
.
style
.
width
=
`
${
200
}
px`
;
gridview
.
container
.
style
.
height
=
`
${
200
}
px`
;
const
container
=
$
(
'
.container
'
);
container
.
style
.
position
=
'
absolute
'
;
container
.
style
.
width
=
`
${
200
}
px`
;
container
.
style
.
height
=
`
${
200
}
px`
;
container
.
appendChild
(
gridview
.
element
);
});
teardown
(
function
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录