Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3ac72114
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 搜索 >>
提交
3ac72114
编写于
7月 26, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support bem filter in emmet fixes #30395
上级
5cd4766f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
38 addition
and
20 deletion
+38
-20
extensions/emmet/npm-shrinkwrap.json
extensions/emmet/npm-shrinkwrap.json
+3
-3
extensions/emmet/package.json
extensions/emmet/package.json
+1
-1
extensions/emmet/src/abbreviationActions.ts
extensions/emmet/src/abbreviationActions.ts
+23
-16
extensions/emmet/src/test/abbreviationAction.test.ts
extensions/emmet/src/test/abbreviationAction.test.ts
+11
-0
未找到文件。
extensions/emmet/npm-shrinkwrap.json
浏览文件 @
3ac72114
...
...
@@ -123,9 +123,9 @@
"resolved"
:
"https://registry.npmjs.org/image-size/-/image-size-0.5.5.tgz"
},
"vscode-emmet-helper"
:
{
"version"
:
"
0.0.29
"
,
"from"
:
"vscode-emmet-helper@
0.0.29
"
,
"resolved"
:
"https://registry.npmjs.org/vscode-emmet-helper/-/vscode-emmet-helper-
0.0.29
.tgz"
"version"
:
"
1.0.0
"
,
"from"
:
"vscode-emmet-helper@
1.0.0
"
,
"resolved"
:
"https://registry.npmjs.org/vscode-emmet-helper/-/vscode-emmet-helper-
1.0.0
.tgz"
},
"vscode-languageserver-types"
:
{
"version"
:
"3.3.0"
,
...
...
extensions/emmet/package.json
浏览文件 @
3ac72114
...
...
@@ -74,7 +74,7 @@
"@emmetio/html-matcher"
:
"^0.3.1"
,
"@emmetio/css-parser"
:
"^0.3.0"
,
"@emmetio/math-expression"
:
"^0.1.1"
,
"vscode-emmet-helper"
:
"^
0.0.29
"
,
"vscode-emmet-helper"
:
"^
1.0.0
"
,
"vscode-languageserver-types"
:
"^3.0.3"
,
"image-size"
:
"^0.5.2"
}
...
...
extensions/emmet/src/abbreviationActions.ts
浏览文件 @
3ac72114
...
...
@@ -7,13 +7,14 @@ import * as vscode from 'vscode';
import
{
expand
}
from
'
@emmetio/expand-abbreviation
'
;
import
{
Node
,
HtmlNode
,
Rule
}
from
'
EmmetNode
'
;
import
{
getNode
,
getInnerRange
,
getMappingForIncludedLanguages
,
parseDocument
,
validate
}
from
'
./util
'
;
import
{
getExpandOptions
,
extractAbbreviation
,
isStyleSheet
,
isAbbreviationValid
,
getEmmetMode
}
from
'
vscode-emmet-helper
'
;
import
{
getExpandOptions
,
extractAbbreviation
,
extractAbbreviationFromText
,
isStyleSheet
,
isAbbreviationValid
,
getEmmetMode
}
from
'
vscode-emmet-helper
'
;
interface
ExpandAbbreviationInput
{
syntax
:
string
;
abbreviation
:
string
;
rangeToReplace
:
vscode
.
Range
;
textToWrap
?:
string
;
filters
?:
string
[];
}
export
function
wrapWithAbbreviation
(
args
)
{
...
...
@@ -65,11 +66,12 @@ export function expandAbbreviation(args) {
let
firstAbbreviation
:
string
;
let
allAbbreviationsSame
:
boolean
=
true
;
let
getAbbreviation
=
(
document
:
vscode
.
TextDocument
,
selection
:
vscode
.
Selection
,
position
:
vscode
.
Position
,
isHtml
:
boolean
):
[
vscode
.
Range
,
string
]
=>
{
let
getAbbreviation
=
(
document
:
vscode
.
TextDocument
,
selection
:
vscode
.
Selection
,
position
:
vscode
.
Position
,
isHtml
:
boolean
):
[
vscode
.
Range
,
string
,
string
[]
]
=>
{
let
rangeToReplace
:
vscode
.
Range
=
selection
;
let
abbr
eviation
=
document
.
getText
(
rangeToReplace
);
let
abbr
=
document
.
getText
(
rangeToReplace
);
if
(
!
rangeToReplace
.
isEmpty
)
{
return
[
rangeToReplace
,
abbreviation
];
let
{
abbreviation
,
filters
}
=
extractAbbreviationFromText
(
abbr
);
return
[
rangeToReplace
,
abbreviation
,
filters
];
}
// Expand cases like <div to <div></div> explicitly
...
...
@@ -79,17 +81,18 @@ export function expandAbbreviation(args) {
const
textTillPosition
=
currentLine
.
substr
(
0
,
position
.
character
);
let
matches
=
textTillPosition
.
match
(
/<
(\w
+
)
$/
);
if
(
matches
)
{
abbr
eviation
=
matches
[
1
];
rangeToReplace
=
new
vscode
.
Range
(
position
.
translate
(
0
,
-
(
abbr
eviation
.
length
+
1
)),
position
);
return
[
rangeToReplace
,
abbr
eviation
];
abbr
=
matches
[
1
];
rangeToReplace
=
new
vscode
.
Range
(
position
.
translate
(
0
,
-
(
abbr
.
length
+
1
)),
position
);
return
[
rangeToReplace
,
abbr
,
[]
];
}
}
return
extractAbbreviation
(
editor
.
document
,
position
);
let
{
abbreviationRange
,
abbreviation
,
filters
}
=
extractAbbreviation
(
editor
.
document
,
position
);
return
[
new
vscode
.
Range
(
abbreviationRange
.
start
.
line
,
abbreviationRange
.
start
.
character
,
abbreviationRange
.
end
.
line
,
abbreviationRange
.
end
.
character
),
abbreviation
,
filters
];
};
editor
.
selections
.
forEach
(
selection
=>
{
let
position
=
selection
.
isReversed
?
selection
.
anchor
:
selection
.
active
;
let
[
rangeToReplace
,
abbreviation
]
=
getAbbreviation
(
editor
.
document
,
selection
,
position
,
syntax
===
'
html
'
);
let
[
rangeToReplace
,
abbreviation
,
filters
]
=
getAbbreviation
(
editor
.
document
,
selection
,
position
,
syntax
===
'
html
'
);
if
(
!
isAbbreviationValid
(
syntax
,
abbreviation
))
{
vscode
.
window
.
showErrorMessage
(
'
Emmet: Invalid abbreviation
'
);
return
;
...
...
@@ -106,7 +109,7 @@ export function expandAbbreviation(args) {
allAbbreviationsSame
=
false
;
}
abbreviationList
.
push
({
syntax
,
abbreviation
,
rangeToReplace
});
abbreviationList
.
push
({
syntax
,
abbreviation
,
rangeToReplace
,
filters
});
});
return
expandAbbreviationInRange
(
editor
,
abbreviationList
,
allAbbreviationsSame
);
...
...
@@ -194,13 +197,17 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex
*/
function
expandAbbr
(
input
:
ExpandAbbreviationInput
):
string
{
const
emmetConfig
=
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
);
const
expandOptions
=
getExpandOptions
(
emmetConfig
[
'
syntaxProfiles
'
],
emmetConfig
[
'
variables
'
],
input
.
syntax
,
input
.
textToWrap
);
const
expandOptions
=
getExpandOptions
(
input
.
syntax
,
emmetConfig
[
'
syntaxProfiles
'
],
emmetConfig
[
'
variables
'
],
input
.
filters
);
// Below fixes https://github.com/Microsoft/vscode/issues/29898
// With this, Emmet formats inline elements as block elements
// ensuring the wrapped multi line text does not get merged to a single line
if
(
input
.
textToWrap
&&
!
input
.
rangeToReplace
.
isSingleLine
)
{
expandOptions
.
profile
[
'
inlineBreak
'
]
=
1
;
if
(
input
.
textToWrap
)
{
expandOptions
[
'
text
'
]
=
input
.
textToWrap
;
// Below fixes https://github.com/Microsoft/vscode/issues/29898
// With this, Emmet formats inline elements as block elements
// ensuring the wrapped multi line text does not get merged to a single line
if
(
!
input
.
rangeToReplace
.
isSingleLine
)
{
expandOptions
.
profile
[
'
inlineBreak
'
]
=
1
;
}
}
try
{
...
...
extensions/emmet/src/test/abbreviationAction.test.ts
浏览文件 @
3ac72114
...
...
@@ -21,6 +21,12 @@ const cssContents = `
}
`
;
const
bemFilterExample
=
'
ul.search-form._wide>li.-querystring+li.-btn_large|bem
'
;
const
expectedBemFilterOutput
=
`<ul class="search-form search-form_wide">
<li class="search-form__querystring"></li>
<li class="search-form__btn search-form__btn_large"></li>
</ul>`
;
const
htmlContents
=
`
<body class="header">
<ul class="nav main">
...
...
@@ -37,6 +43,7 @@ const htmlContents = `
m10
}
</style>
${
bemFilterExample
}
</body>
`
;
...
...
@@ -147,6 +154,10 @@ suite('Tests for Expand Abbreviations (HTML)', () => {
});
});
test
(
'
Expand using bem filter
'
,
()
=>
{
return
testHtmlExpandAbbreviation
(
new
Selection
(
16
,
55
,
16
,
55
),
bemFilterExample
,
expectedBemFilterOutput
);
});
});
suite
(
'
Tests for Expand Abbreviations (CSS)
'
,
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录