Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7a0f65be
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,发现更多精彩内容 >>
提交
7a0f65be
编写于
7月 24, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tests for Remove, Split, Join and Match tags
上级
bf634bf4
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
127 addition
and
7 deletion
+127
-7
extensions/emmet/src/extension.ts
extensions/emmet/src/extension.ts
+2
-2
extensions/emmet/src/removeTag.ts
extensions/emmet/src/removeTag.ts
+1
-4
extensions/emmet/src/splitJoinTag.ts
extensions/emmet/src/splitJoinTag.ts
+1
-1
extensions/emmet/src/test/tagActions.test.ts
extensions/emmet/src/test/tagActions.test.ts
+123
-0
未找到文件。
extensions/emmet/src/extension.ts
浏览文件 @
7a0f65be
...
...
@@ -36,7 +36,7 @@ export function activate(context: vscode.ExtensionContext) {
}));
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
'
emmet.removeTag
'
,
()
=>
{
removeTag
();
re
turn
re
moveTag
();
}));
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
'
emmet.updateTag
'
,
(
inputTag
)
=>
{
...
...
@@ -61,7 +61,7 @@ export function activate(context: vscode.ExtensionContext) {
}));
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
'
emmet.splitJoinTag
'
,
()
=>
{
splitJoinTag
();
return
splitJoinTag
();
}));
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
'
emmet.mergeLines
'
,
()
=>
{
...
...
extensions/emmet/src/removeTag.ts
浏览文件 @
7a0f65be
...
...
@@ -28,7 +28,7 @@ export function removeTag() {
rangesToRemove
=
rangesToRemove
.
concat
(
getRangeToRemove
(
editor
,
rootNode
,
selection
,
indentInSpaces
));
});
editor
.
edit
(
editBuilder
=>
{
return
editor
.
edit
(
editBuilder
=>
{
rangesToRemove
.
forEach
(
range
=>
{
editBuilder
.
replace
(
range
,
''
);
});
...
...
@@ -48,9 +48,6 @@ function getRangeToRemove(editor: vscode.TextEditor, rootNode: HtmlNode, selecti
closeRange
=
new
vscode
.
Range
(
nodeToUpdate
.
close
.
start
,
nodeToUpdate
.
close
.
end
);
}
if
(
!
openRange
.
contains
(
selection
.
start
)
&&
!
closeRange
.
contains
(
selection
.
start
))
{
return
[];
}
let
ranges
=
[
openRange
];
if
(
closeRange
)
{
for
(
let
i
=
openRange
.
start
.
line
+
1
;
i
<=
closeRange
.
start
.
line
;
i
++
)
{
...
...
extensions/emmet/src/splitJoinTag.ts
浏览文件 @
7a0f65be
...
...
@@ -18,7 +18,7 @@ export function splitJoinTag() {
return
;
}
editor
.
edit
(
editBuilder
=>
{
return
editor
.
edit
(
editBuilder
=>
{
editor
.
selections
.
reverse
().
forEach
(
selection
=>
{
let
[
rangeToReplace
,
textToReplaceWith
]
=
getRangesToReplace
(
editor
.
document
,
selection
,
rootNode
);
if
(
rangeToReplace
&&
textToReplaceWith
)
{
...
...
extensions/emmet/src/test/
updateTag
.test.ts
→
extensions/emmet/src/test/
tagActions
.test.ts
浏览文件 @
7a0f65be
...
...
@@ -7,34 +7,36 @@ import * as assert from 'assert';
import
{
Selection
,
commands
}
from
'
vscode
'
;
import
{
withRandomFileEditor
,
closeAllEditors
}
from
'
./testUtils
'
;
suite
(
'
Tests for Emmet
: Update Tag
'
,
()
=>
{
suite
(
'
Tests for Emmet
actions on html tags
'
,
()
=>
{
teardown
(
closeAllEditors
);
const
contents
=
`
<div>
<div
class="hello"
>
<ul>
<li><span>Hello</span></li>
<li><span>There</span></li>
<div><li><span>Bye</span></li></div>
</ul>
<span/>
</div>
`
;
/*
test('update tag with multiple cursors', () => {
test
(
'
update tag with multiple cursors
'
,
()
=>
{
const
expectedContents
=
`
<div>
<div
class="hello"
>
<ul>
<li><section>Hello</section></li>
<section><span>There</span></section>
<section><li><span>Bye</span></li></section>
</ul>
<span/>
</div>
`
;
return withRandomFileEditor(contents, (editor, doc) => {
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
doc
)
=>
{
editor
.
selections
=
[
new
Selection
(
3
,
17
,
3
,
17
),
// cursor inside tags
new Selection(4,
14, 4, 14
), // cursor inside opening tag
new Selection(5,
47, 5, 47
), // cursor inside closing tag
new
Selection
(
4
,
5
,
4
,
5
),
// cursor inside opening tag
new
Selection
(
5
,
35
,
5
,
35
),
// cursor inside closing tag
];
return
commands
.
executeCommand
(
'
emmet.updateTag
'
,
'
section
'
).
then
(()
=>
{
...
...
@@ -42,5 +44,80 @@ suite('Tests for Emmet: Update Tag', () => {
return
Promise
.
resolve
();
});
});
}); */
});
test
(
'
remove tag with mutliple cursors
'
,
()
=>
{
const
expectedContents
=
`
<div class="hello">
<ul>
<li>Hello</li>
<span>There</span>
<li><span>Bye</span></li>
</ul>
<span/>
</div>
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
doc
)
=>
{
editor
.
selections
=
[
new
Selection
(
3
,
17
,
3
,
17
),
// cursor inside tags
new
Selection
(
4
,
5
,
4
,
5
),
// cursor inside opening tag
new
Selection
(
5
,
35
,
5
,
35
),
// cursor inside closing tag
];
return
commands
.
executeCommand
(
'
emmet.removeTag
'
).
then
(()
=>
{
assert
.
equal
(
doc
.
getText
(),
expectedContents
);
return
Promise
.
resolve
();
});
});
});
test
(
'
split/join tag with mutliple cursors
'
,
()
=>
{
const
expectedContents
=
`
<div class="hello">
<ul>
<li><span/></li>
<li><span>There</span></li>
<div><li><span>Bye</span></li></div>
</ul>
<span></span>
</div>
`
;
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
doc
)
=>
{
editor
.
selections
=
[
new
Selection
(
3
,
17
,
3
,
17
),
// join tag
new
Selection
(
7
,
5
,
7
,
5
),
// split tag
];
return
commands
.
executeCommand
(
'
emmet.splitJoinTag
'
).
then
(()
=>
{
assert
.
equal
(
doc
.
getText
(),
expectedContents
);
return
Promise
.
resolve
();
});
});
});
test
(
'
match tag with mutliple cursors
'
,
()
=>
{
return
withRandomFileEditor
(
contents
,
'
html
'
,
(
editor
,
doc
)
=>
{
editor
.
selections
=
[
new
Selection
(
1
,
0
,
1
,
0
),
// just before tag starts, i.e before <
new
Selection
(
1
,
1
,
1
,
1
),
// just before tag name starts
new
Selection
(
1
,
2
,
1
,
2
),
// inside tag name
new
Selection
(
1
,
6
,
1
,
6
),
// after tag name but before opening tag ends
new
Selection
(
1
,
18
,
1
,
18
),
// just before opening tag ends
new
Selection
(
1
,
19
,
1
,
19
),
// just after opening tag ends
];
return
commands
.
executeCommand
(
'
emmet.matchTag
'
).
then
(()
=>
{
editor
.
selections
.
forEach
(
selection
=>
{
assert
.
equal
(
selection
.
active
.
line
,
8
);
assert
.
equal
(
selection
.
active
.
character
,
3
);
assert
.
equal
(
selection
.
anchor
.
line
,
8
);
assert
.
equal
(
selection
.
anchor
.
character
,
3
);
});
return
Promise
.
resolve
();
});
});
});
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录