Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
65f1bd4b
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,体验更适合开发者的 AI 搜索 >>
提交
65f1bd4b
编写于
1月 12, 2018
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow hex color completions from emmet
上级
db95108d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
99 addition
and
8 deletion
+99
-8
extensions/emmet/package.json
extensions/emmet/package.json
+1
-1
extensions/emmet/src/abbreviationActions.ts
extensions/emmet/src/abbreviationActions.ts
+4
-2
extensions/emmet/src/test/cssAbbreviationAction.test.ts
extensions/emmet/src/test/cssAbbreviationAction.test.ts
+91
-2
extensions/emmet/yarn.lock
extensions/emmet/yarn.lock
+3
-3
未找到文件。
extensions/emmet/package.json
浏览文件 @
65f1bd4b
...
...
@@ -310,7 +310,7 @@
"compile"
:
"gulp compile-extension:emmet"
},
"devDependencies"
:
{
"@types/node"
:
"
7.0.4
3"
,
"@types/node"
:
"
8.0.3
3"
,
"vscode"
:
"1.0.1"
},
"dependencies"
:
{
...
...
extensions/emmet/src/abbreviationActions.ts
浏览文件 @
65f1bd4b
...
...
@@ -8,6 +8,7 @@ import { Node, HtmlNode, Rule, Property } from 'EmmetNode';
import
{
getEmmetHelper
,
getNode
,
getInnerRange
,
getMappingForIncludedLanguages
,
parseDocument
,
validate
,
getEmmetConfiguration
,
isStyleSheet
,
getEmmetMode
}
from
'
./util
'
;
const
trimRegex
=
/
[\u
00a0
]
*
[\d
|#|
\-
|
\*
|
\u
2022
]
+
\.?
/
;
const
hexColorRegex
=
/^#
\d
+$/
;
interface
ExpandAbbreviationInput
{
syntax
:
string
;
...
...
@@ -232,17 +233,18 @@ export function isValidLocationForEmmetAbbreviation(document: vscode.TextDocumen
// Fix for https://github.com/Microsoft/vscode/issues/34162
// Other than sass, stylus, we can make use of the terminator tokens to validate position
if
(
syntax
!==
'
sass
'
&&
syntax
!==
'
stylus
'
&&
currentNode
.
type
===
'
property
'
)
{
const
abbreviation
=
document
.
getText
(
new
vscode
.
Range
(
abbreviationRange
.
start
.
line
,
abbreviationRange
.
start
.
character
,
abbreviationRange
.
end
.
line
,
abbreviationRange
.
end
.
character
));
const
propertyNode
=
<
Property
>
currentNode
;
if
(
propertyNode
.
terminatorToken
&&
propertyNode
.
separator
&&
position
.
isAfterOrEqual
(
propertyNode
.
separatorToken
.
end
)
&&
position
.
isBeforeOrEqual
(
propertyNode
.
terminatorToken
.
start
))
{
return
false
;
return
hexColorRegex
.
test
(
abbreviation
)
;
}
if
(
!
propertyNode
.
terminatorToken
&&
propertyNode
.
separator
&&
position
.
isAfterOrEqual
(
propertyNode
.
separatorToken
.
end
))
{
return
false
;
return
hexColorRegex
.
test
(
abbreviation
)
;
}
}
...
...
extensions/emmet/src/test/cssAbbreviationAction.test.ts
浏览文件 @
65f1bd4b
...
...
@@ -70,7 +70,7 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
.foo {
margin: a
margin: 10px;
}
}
`
;
return
withRandomFileEditor
(
testContent
,
'
css
'
,
(
editor
,
doc
)
=>
{
...
...
@@ -87,6 +87,36 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
});
});
test
(
'
Allow hex color when typing property values when there is a property in the next line (CSS)
'
,
()
=>
{
const
testContent
=
`
.foo {
margin: #12
margin: 10px;
}
`
;
return
withRandomFileEditor
(
testContent
,
'
css
'
,
(
editor
,
doc
)
=>
{
editor
.
selection
=
new
Selection
(
2
,
12
,
2
,
12
);
return
expandEmmetAbbreviation
(
null
).
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
testContent
.
replace
(
'
#12
'
,
'
#121212
'
));
const
cancelSrc
=
new
CancellationTokenSource
();
const
completionPromise
=
completionProvider
.
provideCompletionItems
(
editor
.
document
,
new
Position
(
2
,
12
),
cancelSrc
.
token
);
if
(
!
completionPromise
)
{
assert
.
fail
(
'
Completion promise wasnt returned
'
);
return
Promise
.
resolve
();
}
completionPromise
.
then
(
result
=>
{
if
(
!
result
||
!
result
.
items
||
!
result
.
items
.
length
)
{
assert
.
fail
(
'
Completion promise came back empty
'
);
return
Promise
.
resolve
();
}
assert
.
equal
(
result
.
items
[
0
].
label
,
'
#121212
'
);
});
return
Promise
.
resolve
();
});
});
});
test
(
'
Skip when typing property values when there is a property in the previous line (CSS)
'
,
()
=>
{
const
testContent
=
`
.foo {
...
...
@@ -109,11 +139,41 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
});
});
test
(
'
Allow hex color when typing property values when there is a property in the previous line (CSS)
'
,
()
=>
{
const
testContent
=
`
.foo {
margin: 10px;
margin: #12
}
`
;
return
withRandomFileEditor
(
testContent
,
'
css
'
,
(
editor
,
doc
)
=>
{
editor
.
selection
=
new
Selection
(
3
,
12
,
3
,
12
);
return
expandEmmetAbbreviation
(
null
).
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
testContent
.
replace
(
'
#12
'
,
'
#121212
'
));
const
cancelSrc
=
new
CancellationTokenSource
();
const
completionPromise
=
completionProvider
.
provideCompletionItems
(
editor
.
document
,
new
Position
(
3
,
12
),
cancelSrc
.
token
);
if
(
!
completionPromise
)
{
assert
.
fail
(
'
Completion promise wasnt returned
'
);
return
Promise
.
resolve
();
}
completionPromise
.
then
(
result
=>
{
if
(
!
result
||
!
result
.
items
||
!
result
.
items
.
length
)
{
assert
.
fail
(
'
Completion promise came back empty
'
);
return
Promise
.
resolve
();
}
assert
.
equal
(
result
.
items
[
0
].
label
,
'
#121212
'
);
});
return
Promise
.
resolve
();
});
});
});
test
(
'
Skip when typing property values when it is the only property in the rule (CSS)
'
,
()
=>
{
const
testContent
=
`
.foo {
margin: a
}
}
`
;
return
withRandomFileEditor
(
testContent
,
'
css
'
,
(
editor
,
doc
)
=>
{
...
...
@@ -130,6 +190,35 @@ suite('Tests for Expand Abbreviations (CSS)', () => {
});
});
test
(
'
Allow hex colors when typing property values when it is the only property in the rule (CSS)
'
,
()
=>
{
const
testContent
=
`
.foo {
margin: #12
}
`
;
return
withRandomFileEditor
(
testContent
,
'
css
'
,
(
editor
,
doc
)
=>
{
editor
.
selection
=
new
Selection
(
2
,
12
,
2
,
12
);
return
expandEmmetAbbreviation
(
null
).
then
(()
=>
{
assert
.
equal
(
editor
.
document
.
getText
(),
testContent
.
replace
(
'
#12
'
,
'
#121212
'
));
const
cancelSrc
=
new
CancellationTokenSource
();
const
completionPromise
=
completionProvider
.
provideCompletionItems
(
editor
.
document
,
new
Position
(
2
,
12
),
cancelSrc
.
token
);
if
(
!
completionPromise
)
{
assert
.
fail
(
'
Completion promise wasnt returned
'
);
return
Promise
.
resolve
();
}
completionPromise
.
then
(
result
=>
{
if
(
!
result
||
!
result
.
items
||
!
result
.
items
.
length
)
{
assert
.
fail
(
'
Completion promise came back empty
'
);
return
Promise
.
resolve
();
}
assert
.
equal
(
result
.
items
[
0
].
label
,
'
#121212
'
);
});
return
Promise
.
resolve
();
});
});
});
test
(
'
Expand abbreviation in completion list (CSS)
'
,
()
=>
{
const
abbreviation
=
'
m10
'
;
const
expandedText
=
'
margin: 10px;
'
;
...
...
extensions/emmet/yarn.lock
浏览文件 @
65f1bd4b
...
...
@@ -35,9 +35,9 @@
version "2.2.0"
resolved "https://registry.yarnpkg.com/@emmetio/stream-reader/-/stream-reader-2.2.0.tgz#46cffea119a0a003312a21c2d9b5628cb5fcd442"
"@types/node@
7.0.4
3":
version "
7.0.4
3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-
7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c
"
"@types/node@
8.0.3
3":
version "
8.0.3
3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-
8.0.33.tgz#1126e94374014e54478092830704f6ea89df04cd
"
ajv@^5.1.0:
version "5.3.0"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录