Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6030187b
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,发现更多精彩内容 >>
提交
6030187b
编写于
7月 25, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tests for Emmet Balance In/Out
上级
0a4fa1e7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
63 addition
and
18 deletion
+63
-18
extensions/emmet/src/balance.ts
extensions/emmet/src/balance.ts
+7
-4
extensions/emmet/src/test/editSelectItem.test.ts
extensions/emmet/src/test/editSelectItem.test.ts
+56
-14
未找到文件。
extensions/emmet/src/balance.ts
浏览文件 @
6030187b
...
...
@@ -59,15 +59,18 @@ function getRangeToBalanceOut(document: vscode.TextDocument, selection: vscode.S
}
function
getRangeToBalanceIn
(
document
:
vscode
.
TextDocument
,
selection
:
vscode
.
Selection
,
rootNode
:
HtmlNode
):
vscode
.
Selection
{
let
nodeToBalance
=
<
HtmlNode
>
getNode
(
rootNode
,
selection
.
start
);
let
nodeToBalance
=
<
HtmlNode
>
getNode
(
rootNode
,
selection
.
start
,
true
);
if
(
!
nodeToBalance
)
{
return
;
}
if
(
selection
.
start
.
isEqual
(
nodeToBalance
.
start
)
&&
selection
.
end
.
isEqual
(
nodeToBalance
.
end
)
&&
nodeToBalance
.
close
)
{
return
new
vscode
.
Selection
(
nodeToBalance
.
open
.
end
,
nodeToBalance
.
close
.
start
);
}
if
(
!
nodeToBalance
.
firstChild
)
{
if
(
nodeToBalance
.
close
)
{
return
new
vscode
.
Selection
(
nodeToBalance
.
open
.
end
,
nodeToBalance
.
close
.
start
);
}
return
;
}
...
...
extensions/emmet/src/test/editSelectItem.test.ts
浏览文件 @
6030187b
...
...
@@ -8,6 +8,7 @@ import { Selection } from 'vscode';
import
{
withRandomFileEditor
,
closeAllEditors
}
from
'
./testUtils
'
;
import
{
fetchEditPoint
}
from
'
../editPoint
'
;
import
{
fetchSelectItem
}
from
'
../selectItem
'
;
import
{
balanceOut
,
balanceIn
}
from
'
../balance
'
;
suite
(
'
Tests for Next/Previous Select/Edit point actions
'
,
()
=>
{
teardown
(
closeAllEditors
);
...
...
@@ -48,8 +49,8 @@ suite('Tests for Next/Previous Select/Edit point actions', () => {
</div>
<div class="header">
<ul class="nav main">
<li class="item">Item 1</li>
<li class="item">Item 2</li>
<li class="item
1
">Item 1</li>
<li class="item
2
">Item 2</li>
</ul>
</div>
</body>
...
...
@@ -63,13 +64,13 @@ suite('Tests for Next/Previous Select/Edit point actions', () => {
let
expectedNextEditPoints
:
[
number
,
number
][]
=
[[
4
,
16
],
[
6
,
8
],
[
10
,
2
],
[
20
,
0
]];
expectedNextEditPoints
.
forEach
(([
line
,
col
])
=>
{
fetchEditPoint
(
'
next
'
);
testSelection
(
editor
.
selection
,
line
,
col
);
testSelection
(
editor
.
selection
,
col
,
line
);
});
let
expectedPrevEditPoints
=
[[
10
,
2
],
[
6
,
8
],
[
4
,
16
],
[
0
,
0
]];
expectedPrevEditPoints
.
forEach
(([
line
,
col
])
=>
{
fetchEditPoint
(
'
prev
'
);
testSelection
(
editor
.
selection
,
line
,
col
);
testSelection
(
editor
.
selection
,
col
,
line
);
});
return
Promise
.
resolve
();
...
...
@@ -98,13 +99,13 @@ suite('Tests for Next/Previous Select/Edit point actions', () => {
];
expectedNextItemPoints
.
forEach
(([
line
,
colstart
,
colend
])
=>
{
fetchSelectItem
(
'
next
'
);
testSelection
(
editor
.
selection
,
line
,
colstart
,
colend
);
testSelection
(
editor
.
selection
,
colstart
,
line
,
colend
);
});
editor
.
selections
=
[
new
Selection
(
6
,
15
,
6
,
15
)];
expectedNextItemPoints
.
reverse
().
forEach
(([
line
,
colstart
,
colend
])
=>
{
fetchSelectItem
(
'
prev
'
);
testSelection
(
editor
.
selection
,
line
,
colstart
,
colend
);
testSelection
(
editor
.
selection
,
colstart
,
line
,
colend
);
});
return
Promise
.
resolve
();
...
...
@@ -129,13 +130,13 @@ suite('Tests for Next/Previous Select/Edit point actions', () => {
];
expectedNextItemPoints
.
forEach
(([
line
,
colstart
,
colend
])
=>
{
fetchSelectItem
(
'
next
'
);
testSelection
(
editor
.
selection
,
line
,
colstart
,
colend
);
testSelection
(
editor
.
selection
,
colstart
,
line
,
colend
);
});
editor
.
selections
=
[
new
Selection
(
9
,
0
,
9
,
0
)];
expectedNextItemPoints
.
reverse
().
forEach
(([
line
,
colstart
,
colend
])
=>
{
fetchSelectItem
(
'
prev
'
);
testSelection
(
editor
.
selection
,
line
,
colstart
,
colend
);
testSelection
(
editor
.
selection
,
colstart
,
line
,
colend
);
});
return
Promise
.
resolve
();
...
...
@@ -160,13 +161,49 @@ suite('Tests for Next/Previous Select/Edit point actions', () => {
];
expectedNextItemPoints
.
forEach
(([
line
,
colstart
,
colend
])
=>
{
fetchSelectItem
(
'
next
'
);
testSelection
(
editor
.
selection
,
line
,
colstart
,
colend
);
testSelection
(
editor
.
selection
,
colstart
,
line
,
colend
);
});
editor
.
selections
=
[
new
Selection
(
8
,
0
,
8
,
0
)];
expectedNextItemPoints
.
reverse
().
forEach
(([
line
,
colstart
,
colend
])
=>
{
fetchSelectItem
(
'
prev
'
);
testSelection
(
editor
.
selection
,
line
,
colstart
,
colend
);
testSelection
(
editor
.
selection
,
colstart
,
line
,
colend
);
});
return
Promise
.
resolve
();
});
});
test
(
'
Emmet Balance Out in html file
'
,
function
():
any
{
return
withRandomFileEditor
(
htmlContents
,
'
html
'
,
(
editor
,
doc
)
=>
{
editor
.
selections
=
[
new
Selection
(
14
,
6
,
14
,
10
)];
let
expectedBalanceOutRanges
:
[
number
,
number
,
number
,
number
][]
=
[
[
14
,
3
,
14
,
32
],
// <li class="item1">Item 1</li>
[
13
,
23
,
16
,
2
],
// inner contents of <ul class="nav main">
[
13
,
2
,
16
,
7
],
// outer contents of <ul class="nav main">
[
12
,
21
,
17
,
1
],
// inner contents of <div class="header">
[
12
,
1
,
17
,
7
],
// outer contents of <div class="header">
[
8
,
6
,
18
,
0
],
// inner contents of <body>
[
8
,
0
,
18
,
7
],
// outer contents of <body>
[
2
,
16
,
19
,
0
],
// inner contents of <html>
[
2
,
0
,
19
,
7
],
// outer contents of <html>
];
expectedBalanceOutRanges
.
forEach
(([
linestart
,
colstart
,
lineend
,
colend
])
=>
{
balanceOut
();
testSelection
(
editor
.
selection
,
colstart
,
linestart
,
colend
,
lineend
);
});
editor
.
selections
=
[
new
Selection
(
12
,
7
,
12
,
7
)];
let
expectedBalanceInRanges
:
[
number
,
number
,
number
,
number
][]
=
[
[
13
,
2
,
16
,
7
],
// outer contents of <ul class="nav main">
[
13
,
23
,
16
,
2
],
// inner contents of <ul class="nav main">
[
14
,
3
,
14
,
32
],
// <li class="item1">Item 1</li>
[
14
,
21
,
14
,
27
]
// Item 1
];
expectedBalanceInRanges
.
forEach
(([
linestart
,
colstart
,
lineend
,
colend
])
=>
{
balanceIn
();
testSelection
(
editor
.
selection
,
colstart
,
linestart
,
colend
,
lineend
);
});
return
Promise
.
resolve
();
...
...
@@ -175,11 +212,16 @@ suite('Tests for Next/Previous Select/Edit point actions', () => {
});
function
testSelection
(
selection
:
Selection
,
line
:
number
,
startChar
:
number
,
endChar
?:
number
)
{
assert
.
equal
(
selection
.
isSingleLine
,
true
);
assert
.
equal
(
selection
.
anchor
.
line
,
line
);
function
testSelection
(
selection
:
Selection
,
startChar
:
number
,
startline
:
number
,
endChar
?:
number
,
endLine
?:
number
)
{
assert
.
equal
(
selection
.
anchor
.
line
,
start
line
);
assert
.
equal
(
selection
.
anchor
.
character
,
startChar
);
if
(
!
endChar
)
{
if
(
!
endLine
&&
endLine
!==
0
)
{
assert
.
equal
(
selection
.
isSingleLine
,
true
);
}
else
{
assert
.
equal
(
selection
.
active
.
line
,
endLine
);
}
if
(
!
endChar
&&
endChar
!==
0
)
{
assert
.
equal
(
selection
.
isEmpty
,
true
);
}
else
{
assert
.
equal
(
selection
.
active
.
character
,
endChar
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录