Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ac60143a
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ac60143a
编写于
6月 20, 2017
作者:
R
Ramya Achutha Rao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Honor emmet.extensionsPath setting for variables and profile
上级
91008076
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
67 addition
and
12 deletion
+67
-12
extensions/emmet/package.json
extensions/emmet/package.json
+1
-7
extensions/emmet/src/abbreviationActions.ts
extensions/emmet/src/abbreviationActions.ts
+2
-2
extensions/emmet/src/extension.ts
extensions/emmet/src/extension.ts
+5
-0
extensions/emmet/src/util.ts
extensions/emmet/src/util.ts
+59
-3
未找到文件。
extensions/emmet/package.json
浏览文件 @
ac60143a
...
...
@@ -57,13 +57,7 @@
"default"
:
"
\n
"
}
},
"default"
:{
"lang"
:
"en"
,
"locale"
:
"en-US"
,
"charset"
:
"UTF-8"
,
"indentation"
:
"
\t
"
,
"newline"
:
"
\n
"
},
"default"
:{},
"description"
:
"Variables to be used in emmet snippets"
}
}
...
...
extensions/emmet/src/abbreviationActions.ts
浏览文件 @
ac60143a
...
...
@@ -10,7 +10,7 @@ import parseStylesheet from '@emmetio/css-parser';
import
parse
from
'
@emmetio/html-matcher
'
;
import
Node
from
'
@emmetio/node
'
;
import
{
getSyntax
,
getProfile
,
isStyleSheet
,
getNode
,
getInnerRange
}
from
'
./util
'
;
import
{
getSyntax
,
getProfile
,
getVariables
,
isStyleSheet
,
getNode
,
getInnerRange
}
from
'
./util
'
;
import
{
DocumentStreamReader
}
from
'
./bufferStream
'
;
const
field
=
(
index
,
placeholder
)
=>
`
\$
{
${
index
}${
placeholder
?
'
:
'
+
placeholder
:
''
}
}`
;
...
...
@@ -147,7 +147,7 @@ function getExpandOptions(syntax: string, textToReplace?: string) {
syntax
:
syntax
,
profile
:
getProfile
(
syntax
),
addons
:
syntax
===
'
jsx
'
?
{
'
jsx
'
:
true
}
:
null
,
variables
:
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
)[
'
variables
'
]
,
variables
:
getVariables
()
,
text
:
textToReplace
?
textToReplace
:
''
};
}
\ No newline at end of file
extensions/emmet/src/extension.ts
浏览文件 @
ac60143a
...
...
@@ -15,6 +15,7 @@ import { mergeLines } from './mergeLines';
import
{
toggleComment
}
from
'
./toggleComment
'
;
import
{
fetchEditPoint
}
from
'
./editPoint
'
;
import
{
fetchSelectItem
}
from
'
./selectItem
'
;
import
{
updateExtensionsPath
}
from
'
./util
'
;
const
LANGUAGE_MODES
:
Object
=
{
'
html
'
:
[
'
!
'
,
'
.
'
,
'
}
'
],
...
...
@@ -109,6 +110,10 @@ export function activate(context: vscode.ExtensionContext) {
fetchSelectItem
(
'
prev
'
);
}));
updateExtensionsPath
();
context
.
subscriptions
.
push
(
vscode
.
workspace
.
onDidChangeConfiguration
(()
=>
{
updateExtensionsPath
();
}));
}
export
function
deactivate
()
{
...
...
extensions/emmet/src/util.ts
浏览文件 @
ac60143a
...
...
@@ -7,7 +7,12 @@ import * as vscode from 'vscode';
import
parse
from
'
@emmetio/html-matcher
'
;
import
Node
from
'
@emmetio/node
'
;
import
{
DocumentStreamReader
}
from
'
./bufferStream
'
;
import
*
as
path
from
'
path
'
;
import
*
as
fs
from
'
fs
'
;
let
variablesFromFile
=
{};
let
profilesFromFile
=
{};
let
emmetExtensionsPath
=
''
;
export
function
validate
(
allowStylesheet
:
boolean
=
true
):
boolean
{
let
editor
=
vscode
.
window
.
activeTextEditor
;
if
(
!
editor
)
{
...
...
@@ -36,8 +41,10 @@ export function isStyleSheet(syntax): boolean {
}
export
function
getProfile
(
syntax
:
string
):
any
{
let
config
=
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
)[
'
syntaxProfiles
'
]
||
{};
let
options
=
config
[
syntax
];
let
profilesFromSettings
=
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
)[
'
syntaxProfiles
'
]
||
{};
let
profilesConfig
=
Object
.
assign
({},
profilesFromFile
,
profilesFromSettings
);
let
options
=
profilesConfig
[
syntax
];
if
(
!
options
||
typeof
options
===
'
string
'
)
{
if
(
options
===
'
xhtml
'
)
{
return
{
...
...
@@ -84,6 +91,46 @@ export function getProfile(syntax: string): any {
return
newOptions
;
}
export
function
getVariables
():
any
{
let
variablesFromSettings
=
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
)[
'
variables
'
];
return
Object
.
assign
({},
variablesFromFile
,
variablesFromSettings
);
}
export
function
updateExtensionsPath
()
{
let
currentEmmetExtensionsPath
=
vscode
.
workspace
.
getConfiguration
(
'
emmet
'
)[
'
extensionsPath
'
];
if
(
emmetExtensionsPath
!==
currentEmmetExtensionsPath
)
{
emmetExtensionsPath
=
currentEmmetExtensionsPath
;
if
(
emmetExtensionsPath
&&
emmetExtensionsPath
.
trim
())
{
let
dirPath
=
path
.
isAbsolute
(
emmetExtensionsPath
)
?
emmetExtensionsPath
:
path
.
join
(
vscode
.
workspace
.
rootPath
,
emmetExtensionsPath
);
let
snippetsPath
=
path
.
join
(
dirPath
,
'
snippets.json
'
);
let
profilesPath
=
path
.
join
(
dirPath
,
'
syntaxProfiles.json
'
);
if
(
dirExists
(
dirPath
))
{
fs
.
readFile
(
snippetsPath
,
(
err
,
snippetsData
)
=>
{
if
(
err
)
{
return
;
}
try
{
let
snippetsJson
=
JSON
.
parse
(
snippetsData
.
toString
());
variablesFromFile
=
snippetsJson
[
'
variables
'
];
}
catch
(
e
)
{
}
});
fs
.
readFile
(
profilesPath
,
(
err
,
profilesData
)
=>
{
if
(
err
)
{
return
;
}
try
{
profilesFromFile
=
JSON
.
parse
(
profilesData
.
toString
());
}
catch
(
e
)
{
}
});
}
}
}
}
export
function
getOpenCloseRange
(
document
:
vscode
.
TextDocument
,
position
:
vscode
.
Position
):
[
vscode
.
Range
,
vscode
.
Range
]
{
let
rootNode
:
Node
=
parse
(
new
DocumentStreamReader
(
document
));
let
nodeToUpdate
=
getNode
(
rootNode
,
position
);
...
...
@@ -259,4 +306,13 @@ export function sameNodes(node1: Node, node2: Node): boolean {
return
false
;
}
return
(
<
vscode
.
Position
>
node1
.
start
).
isEqual
(
node2
.
start
)
&&
(
<
vscode
.
Position
>
node1
.
end
).
isEqual
(
node2
.
end
);
}
\ No newline at end of file
}
function
dirExists
(
dirPath
:
string
):
boolean
{
try
{
return
fs
.
statSync
(
dirPath
).
isDirectory
();
}
catch
(
e
)
{
return
false
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录