Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f3251182
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,发现更多精彩内容 >>
未验证
提交
f3251182
编写于
11月 22, 2018
作者:
J
Johannes Rieken
提交者:
GitHub
11月 22, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #63572 from karanisverma/dev
fix: #55946 Added comment snippet variable
上级
3c97c469
4abddd86
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
2 deletion
+29
-2
src/vs/editor/contrib/snippet/snippetSession.ts
src/vs/editor/contrib/snippet/snippetSession.ts
+2
-1
src/vs/editor/contrib/snippet/snippetVariables.ts
src/vs/editor/contrib/snippet/snippetVariables.ts
+27
-1
未找到文件。
src/vs/editor/contrib/snippet/snippetSession.ts
浏览文件 @
f3251182
...
...
@@ -17,7 +17,7 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
import
{
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Choice
,
Placeholder
,
SnippetParser
,
Text
,
TextmateSnippet
}
from
'
./snippetParser
'
;
import
{
ClipboardBasedVariableResolver
,
CompositeSnippetVariableResolver
,
ModelBasedVariableResolver
,
SelectionBasedVariableResolver
,
TimeBasedVariableResolver
}
from
'
./snippetVariables
'
;
import
{
ClipboardBasedVariableResolver
,
CompositeSnippetVariableResolver
,
ModelBasedVariableResolver
,
SelectionBasedVariableResolver
,
TimeBasedVariableResolver
,
CommentBasedVariableResolver
}
from
'
./snippetVariables
'
;
import
{
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
*
as
colors
from
'
vs/platform/theme/common/colorRegistry
'
;
...
...
@@ -402,6 +402,7 @@ export class SnippetSession {
modelBasedVariableResolver
,
new
ClipboardBasedVariableResolver
(
clipboardService
,
idx
,
indexedSelections
.
length
),
new
SelectionBasedVariableResolver
(
model
,
selection
),
new
CommentBasedVariableResolver
(
model
),
new
TimeBasedVariableResolver
]));
...
...
src/vs/editor/contrib/snippet/snippetVariables.ts
浏览文件 @
f3251182
...
...
@@ -8,6 +8,7 @@ import { basename, dirname } from 'vs/base/common/paths';
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
VariableResolver
,
Variable
,
Text
}
from
'
vs/editor/contrib/snippet/snippetParser
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
getLeadingWhitespace
,
commonPrefixLength
,
isFalsyOrWhitespace
,
pad
}
from
'
vs/base/common/strings
'
;
import
{
IClipboardService
}
from
'
vs/platform/clipboard/common/clipboardService
'
;
...
...
@@ -34,6 +35,9 @@ export const KnownSnippetVariableNames = Object.freeze({
'
TM_FILENAME_BASE
'
:
true
,
'
TM_DIRECTORY
'
:
true
,
'
TM_FILEPATH
'
:
true
,
'
BLOCK_COMMENT_START
'
:
true
,
'
BLOCK_COMMENT_END
'
:
true
,
'
LINE_COMMENT
'
:
true
,
});
export
class
CompositeSnippetVariableResolver
implements
VariableResolver
{
...
...
@@ -180,7 +184,29 @@ export class ClipboardBasedVariableResolver implements VariableResolver {
}
}
}
export
class
CommentBasedVariableResolver
implements
VariableResolver
{
constructor
(
private
readonly
_model
:
ITextModel
)
{
//
}
resolve
(
variable
:
Variable
):
string
|
undefined
{
const
{
name
}
=
variable
;
const
language
=
this
.
_model
.
getLanguageIdentifier
();
const
config
=
LanguageConfigurationRegistry
.
getComments
(
language
.
id
);
if
(
!
config
)
{
return
undefined
;
}
if
(
name
===
'
LINE_COMMENT
'
)
{
return
config
.
lineCommentToken
||
undefined
;
}
else
if
(
name
===
'
BLOCK_COMMENT_START
'
)
{
return
config
.
blockCommentStartToken
||
undefined
;
}
else
if
(
name
===
'
BLOCK_COMMENT_END
'
)
{
return
config
.
blockCommentEndToken
||
undefined
;
}
return
undefined
;
}
}
export
class
TimeBasedVariableResolver
implements
VariableResolver
{
private
static
readonly
dayNames
=
[
nls
.
localize
(
'
Sunday
'
,
"
Sunday
"
),
nls
.
localize
(
'
Monday
'
,
"
Monday
"
),
nls
.
localize
(
'
Tuesday
'
,
"
Tuesday
"
),
nls
.
localize
(
'
Wednesday
'
,
"
Wednesday
"
),
nls
.
localize
(
'
Thursday
'
,
"
Thursday
"
),
nls
.
localize
(
'
Friday
'
,
"
Friday
"
),
nls
.
localize
(
'
Saturday
'
,
"
Saturday
"
)];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录