Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
868b8208
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 搜索 >>
提交
868b8208
编写于
6月 26, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pass syntax from core to Wrap Abbr just like Expand Abbr
上级
7eda8927
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
25 deletion
+35
-25
extensions/emmet/src/abbreviationActions.ts
extensions/emmet/src/abbreviationActions.ts
+31
-21
extensions/emmet/src/extension.ts
extensions/emmet/src/extension.ts
+2
-2
src/vs/workbench/parts/emmet/electron-browser/emmetActions.ts
...vs/workbench/parts/emmet/electron-browser/emmetActions.ts
+2
-2
未找到文件。
extensions/emmet/src/abbreviationActions.ts
浏览文件 @
868b8208
...
...
@@ -8,7 +8,7 @@ import { expand } from '@emmetio/expand-abbreviation';
import
parseStylesheet
from
'
@emmetio/css-parser
'
;
import
parse
from
'
@emmetio/html-matcher
'
;
import
Node
from
'
@emmetio/node
'
;
import
{
get
Syntax
,
get
Node
,
getInnerRange
}
from
'
./util
'
;
import
{
getNode
,
getInnerRange
}
from
'
./util
'
;
import
{
getExpandOptions
,
extractAbbreviation
,
isStyleSheet
,
isAbbreviationValid
}
from
'
vscode-emmet-helper
'
;
import
{
DocumentStreamReader
}
from
'
./bufferStream
'
;
...
...
@@ -19,14 +19,14 @@ interface ExpandAbbreviationInput {
textToWrap
?:
string
;
}
export
function
wrapWithAbbreviation
()
{
let
editor
=
vscode
.
window
.
activeTextEditor
;
if
(
!
editor
)
{
vscode
.
window
.
showInformationMessage
(
'
No editor is active
'
);
export
function
wrapWithAbbreviation
(
args
)
{
const
syntax
=
getSyntaxFromArgs
(
args
);
if
(
!
syntax
)
{
return
;
}
const
editor
=
vscode
.
window
.
activeTextEditor
;
const
newLine
=
editor
.
document
.
eol
===
vscode
.
EndOfLine
.
LF
?
'
\n
'
:
'
\r\n
'
;
let
syntax
=
getSyntax
(
editor
.
document
);
vscode
.
window
.
showInputBox
({
prompt
:
'
Enter Abbreviation
'
}).
then
(
abbreviation
=>
{
if
(
!
abbreviation
||
!
abbreviation
.
trim
()
||
!
isAbbreviationValid
(
syntax
,
abbreviation
))
{
return
;
}
...
...
@@ -69,16 +69,13 @@ export function wrapWithAbbreviation() {
}
export
function
expandAbbreviation
(
args
)
{
let
editor
=
vscode
.
window
.
activeTextEditor
;
if
(
!
editor
)
{
vscode
.
window
.
showInformationMessage
(
'
No editor is active
'
);
const
syntax
=
getSyntaxFromArgs
(
args
);
if
(
!
syntax
)
{
return
;
}
if
(
typeof
args
!==
'
object
'
||
!
args
[
'
syntax
'
])
{
return
;
}
let
syntax
=
args
[
'
syntax
'
];
const
editor
=
vscode
.
window
.
activeTextEditor
;
let
parseContent
=
isStyleSheet
(
syntax
)
?
parseStylesheet
:
parse
;
let
rootNode
:
Node
=
parseContent
(
new
DocumentStreamReader
(
editor
.
document
));
...
...
@@ -141,11 +138,11 @@ export function isValidLocationForEmmetAbbreviation(currentNode: Node, syntax: s
/**
* Expands abbreviations as detailed in expandAbbrList in the editor
* @param editor
* @param expandAbbrList
* @param syntax
* @param insertSameSnippet
* @param preceedingWhiteSpace
* @param editor
* @param expandAbbrList
* @param syntax
* @param insertSameSnippet
* @param preceedingWhiteSpace
*/
function
expandAbbreviationInRange
(
editor
:
vscode
.
TextEditor
,
expandAbbrList
:
ExpandAbbreviationInput
[],
syntax
:
string
,
insertSameSnippet
:
boolean
,
preceedingWhiteSpace
:
string
=
''
)
{
if
(
!
expandAbbrList
||
expandAbbrList
.
length
===
0
)
{
...
...
@@ -167,7 +164,7 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex
}
// Snippet to replace at all cursors are the same
// We can pass all ranges to `editor.insertSnippet` in a single call so that
// We can pass all ranges to `editor.insertSnippet` in a single call so that
// all cursors are maintained after snippet insertion
const
anyExpandAbbrInput
=
expandAbbrList
[
0
];
let
expandedText
=
expandAbbr
(
anyExpandAbbrInput
,
preceedingWhiteSpace
,
newLine
);
...
...
@@ -180,7 +177,7 @@ function expandAbbreviationInRange(editor: vscode.TextEditor, expandAbbrList: Ex
}
/**
* Expands abbreviation as detailed in given input.
* Expands abbreviation as detailed in given input.
* If there is textToWrap, then given preceedingWhiteSpace is applied
*/
function
expandAbbr
(
input
:
ExpandAbbreviationInput
,
preceedingWhiteSpace
:
string
,
newLine
:
string
):
string
{
...
...
@@ -195,4 +192,17 @@ function expandAbbr(input: ExpandAbbreviationInput, preceedingWhiteSpace: string
}
return
expandedText
.
split
(
newLine
).
map
(
line
=>
preceedingWhiteSpace
+
line
).
join
(
newLine
);
}
function
getSyntaxFromArgs
(
args
:
any
):
string
{
let
editor
=
vscode
.
window
.
activeTextEditor
;
if
(
!
editor
)
{
vscode
.
window
.
showInformationMessage
(
'
No editor is active.
'
);
return
;
}
if
(
typeof
args
!==
'
object
'
||
!
args
[
'
syntax
'
])
{
vscode
.
window
.
showInformationMessage
(
'
Cannot resolve language at cursor.
'
);
return
;
}
return
args
[
'
syntax
'
];
}
\ No newline at end of file
extensions/emmet/src/extension.ts
浏览文件 @
868b8208
...
...
@@ -31,8 +31,8 @@ export function activate(context: vscode.ExtensionContext) {
context
.
subscriptions
.
push
(
provider
);
});
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
'
emmet.wrapWithAbbreviation
'
,
()
=>
{
wrapWithAbbreviation
();
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
'
emmet.wrapWithAbbreviation
'
,
(
args
)
=>
{
wrapWithAbbreviation
(
args
);
}));
context
.
subscriptions
.
push
(
vscode
.
commands
.
registerCommand
(
'
emmet.expandAbbreviation
'
,
(
args
)
=>
{
...
...
src/vs/workbench/parts/emmet/electron-browser/emmetActions.ts
浏览文件 @
868b8208
...
...
@@ -297,7 +297,7 @@ export abstract class EmmetEditorAction extends EditorAction {
const
commandService
=
accessor
.
get
(
ICommandService
);
let
mappedCommand
=
configurationService
.
getConfiguration
<
IEmmetConfiguration
>
().
emmet
.
useNewEmmet
?
this
.
actionMap
[
this
.
id
]
:
undefined
;
if
(
mappedCommand
&&
mappedCommand
!==
'
emmet.expandAbbreviation
'
)
{
if
(
mappedCommand
&&
mappedCommand
!==
'
emmet.expandAbbreviation
'
&&
mappedCommand
!==
'
emmet.wrapWithAbbreviation
'
)
{
return
commandService
.
executeCommand
<
void
>
(
mappedCommand
);
}
...
...
@@ -312,7 +312,7 @@ export abstract class EmmetEditorAction extends EditorAction {
this
.
emmetActionName
);
if
(
mappedCommand
===
'
emmet.expandAbbreviation
'
)
{
if
(
mappedCommand
===
'
emmet.expandAbbreviation
'
||
mappedCommand
===
'
emmet.wrapWithAbbreviation
'
)
{
let
syntax
=
editorAccessor
.
getSyntax
();
return
commandService
.
executeCommand
<
void
>
(
mappedCommand
,
{
syntax
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录