Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
b6104acb
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,发现更多精彩内容 >>
提交
b6104acb
编写于
3月 23, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make sure user snippet are sorted before extension snippets, fixes #22933
上级
4cb14c4a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
9 deletion
+24
-9
src/vs/workbench/parts/snippets/electron-browser/TMSnippets.ts
...s/workbench/parts/snippets/electron-browser/TMSnippets.ts
+4
-4
src/vs/workbench/parts/snippets/electron-browser/insertSnippet.ts
...orkbench/parts/snippets/electron-browser/insertSnippet.ts
+1
-1
src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts
...kbench/parts/snippets/electron-browser/snippetsService.ts
+18
-2
src/vs/workbench/parts/snippets/electron-browser/snippetsTracker.ts
...kbench/parts/snippets/electron-browser/snippetsTracker.ts
+1
-2
未找到文件。
src/vs/workbench/parts/snippets/electron-browser/TMSnippets.ts
浏览文件 @
b6104acb
...
...
@@ -84,14 +84,14 @@ export class MainProcessTextMateSnippet implements IWorkbenchContribution {
}
}
export
function
readAndRegisterSnippets
(
snippetService
:
ISnippetsService
,
languageIdentifier
:
LanguageIdentifier
,
filePath
:
string
,
ownerName
:
string
):
TPromise
<
void
>
{
export
function
readAndRegisterSnippets
(
snippetService
:
ISnippetsService
,
languageIdentifier
:
LanguageIdentifier
,
filePath
:
string
,
extensionName
?
:
string
):
TPromise
<
void
>
{
return
readFile
(
filePath
).
then
(
fileContents
=>
{
let
snippets
=
parseSnippetFile
(
fileContents
.
toString
(),
owner
Name
);
let
snippets
=
parseSnippetFile
(
fileContents
.
toString
(),
extension
Name
);
snippetService
.
registerSnippets
(
languageIdentifier
.
id
,
snippets
,
filePath
);
});
}
function
parseSnippetFile
(
snippetFileContent
:
string
,
owner
:
string
):
ISnippet
[]
{
function
parseSnippetFile
(
snippetFileContent
:
string
,
extensionName
?
:
string
):
ISnippet
[]
{
let
snippetsObj
=
parse
(
snippetFileContent
);
if
(
!
snippetsObj
||
typeof
snippetsObj
!==
'
object
'
)
{
return
[];
...
...
@@ -111,7 +111,7 @@ function parseSnippetFile(snippetFileContent: string, owner: string): ISnippet[]
if
(
typeof
prefix
===
'
string
'
&&
typeof
bodyStringOrArray
===
'
string
'
)
{
result
.
push
({
name
,
owner
,
extensionName
,
prefix
,
description
:
snippet
[
'
description
'
]
||
name
,
codeSnippet
:
bodyStringOrArray
...
...
src/vs/workbench/parts/snippets/electron-browser/insertSnippet.ts
浏览文件 @
b6104acb
...
...
@@ -82,7 +82,7 @@ class InsertSnippetAction extends EditorAction {
codeSnippet
:
snippet
,
description
:
undefined
,
name
:
undefined
,
owner
:
undefined
,
extensionName
:
undefined
,
prefix
:
undefined
});
}
...
...
src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts
浏览文件 @
b6104acb
...
...
@@ -26,10 +26,10 @@ export interface ISnippetsService {
export
interface
ISnippet
{
name
:
string
;
owner
:
string
;
prefix
:
string
;
description
:
string
;
codeSnippet
:
string
;
extensionName
?:
string
;
}
interface
ISnippetSuggestion
extends
ISuggestion
{
...
...
@@ -40,6 +40,8 @@ class SnippetsService implements ISnippetsService {
_serviceBrand
:
any
;
private
static
_defaultDetail
=
localize
(
'
detail.userSnippet
'
,
"
User Snippet
"
);
private
_snippets
=
new
Map
<
LanguageId
,
Map
<
string
,
ISnippet
[]
>>
();
constructor
(
...
...
@@ -119,7 +121,7 @@ class SnippetsService implements ISnippetsService {
type
:
'
snippet
'
,
label
:
s
.
prefix
,
get
disambiguateLabel
()
{
return
localize
(
'
snippetSuggest.longLabel
'
,
"
{0}, {1}
"
,
s
.
prefix
,
s
.
name
);
},
detail
:
s
.
owner
,
detail
:
s
.
extensionName
||
SnippetsService
.
_defaultDetail
,
documentation
:
s
.
description
,
insertText
:
s
.
codeSnippet
,
noAutoAccept
:
true
,
...
...
@@ -141,12 +143,26 @@ class SnippetsService implements ISnippetsService {
lastSuggestion
=
suggestion
;
}
result
.
sort
(
SnippetsService
.
_compareSuggestionsByDetail
);
return
result
;
}
private
static
_compareSuggestionsByLabel
(
a
:
ISuggestion
,
b
:
ISuggestion
):
number
{
return
strings
.
compare
(
a
.
label
,
b
.
label
);
}
private
static
_compareSuggestionsByDetail
(
a
:
ISuggestion
,
b
:
ISuggestion
):
number
{
if
(
a
.
detail
===
b
.
detail
)
{
return
0
;
}
else
if
(
a
.
detail
===
SnippetsService
.
_defaultDetail
)
{
return
-
1
;
}
else
if
(
b
.
detail
===
SnippetsService
.
_defaultDetail
)
{
return
1
;
}
else
{
return
strings
.
compare
(
a
.
detail
,
b
.
detail
);
}
}
}
registerSingleton
(
ISnippetsService
,
SnippetsService
);
...
...
src/vs/workbench/parts/snippets/electron-browser/snippetsTracker.ts
浏览文件 @
b6104acb
...
...
@@ -5,7 +5,6 @@
'
use strict
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
workbenchExt
=
require
(
'
vs/workbench/common/contributions
'
);
import
paths
=
require
(
'
vs/base/common/paths
'
);
import
async
=
require
(
'
vs/base/common/async
'
);
...
...
@@ -77,7 +76,7 @@ export class SnippetsTracker implements workbenchExt.IWorkbenchContribution {
var
snippetPath
=
paths
.
join
(
this
.
snippetFolder
,
snippetFile
);
let
languageIdentifier
=
this
.
modeService
.
getLanguageIdentifier
(
modeId
);
if
(
languageIdentifier
)
{
return
readAndRegisterSnippets
(
this
.
snippetService
,
languageIdentifier
,
snippetPath
,
localize
(
'
userSnippet
'
,
"
User Snippet
"
)
);
return
readAndRegisterSnippets
(
this
.
snippetService
,
languageIdentifier
,
snippetPath
);
}
return
undefined
;
}));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录