Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
015f9507
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,发现更多精彩内容 >>
提交
015f9507
编写于
3月 21, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🎨
use async in ExtensionsViewlet
上级
49f03967
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
38 addition
and
29 deletion
+38
-29
src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts
...ch/parts/extensions/electron-browser/extensionsViewlet.ts
+38
-29
未找到文件。
src/vs/workbench/parts/extensions/electron-browser/extensionsViewlet.ts
浏览文件 @
015f9507
...
...
@@ -228,42 +228,51 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
.
done
(
null
,
err
=>
this
.
onError
(
err
));
}
private
doSearch
(
value
:
string
=
''
,
suggestPopular
=
false
):
TPromise
<
any
>
{
return
this
.
progress
(
this
.
query
(
value
))
.
then
(
model
=>
{
if
(
!
value
&&
model
.
length
===
0
&&
suggestPopular
)
{
return
this
.
search
(
'
@sort:installs
'
);
}
private
async
doSearch
(
value
:
string
=
''
,
suggestPopular
=
false
):
TPromise
<
void
>
{
const
model
=
await
this
.
progress
(
this
.
query
(
value
));
this
.
setModel
(
model
);
});
if
(
!
value
&&
model
.
length
===
0
&&
suggestPopular
)
{
return
this
.
search
(
'
@sort:installs
'
);
}
this
.
setModel
(
model
);
}
private
query
(
value
:
string
):
TPromise
<
IPagedModel
<
IExtension
>>
{
private
async
query
(
value
:
string
):
TPromise
<
IPagedModel
<
IExtension
>>
{
if
(
!
value
||
/@installed/i
.
test
(
value
))
{
// Show installed extensions
value
=
value
?
value
.
replace
(
/@installed/g
,
''
).
trim
().
toLowerCase
()
:
''
;
return
this
.
extensionsWorkbenchService
.
queryLocal
()
.
then
(
result
=>
result
.
sort
((
e1
,
e2
)
=>
e1
.
displayName
.
localeCompare
(
e2
.
displayName
)))
.
then
(
result
=>
result
.
filter
(
e
=>
e
.
type
===
LocalExtensionType
.
User
&&
e
.
name
.
toLowerCase
().
indexOf
(
value
)
>
-
1
))
.
then
(
result
=>
new
PagedModel
(
result
));
const
local
=
await
this
.
extensionsWorkbenchService
.
queryLocal
();
const
result
=
local
.
sort
((
e1
,
e2
)
=>
e1
.
displayName
.
localeCompare
(
e2
.
displayName
))
.
filter
(
e
=>
e
.
type
===
LocalExtensionType
.
User
&&
e
.
name
.
toLowerCase
().
indexOf
(
value
)
>
-
1
);
return
new
PagedModel
(
result
);
}
if
(
/@outdated/i
.
test
(
value
))
{
value
=
value
.
replace
(
/@outdated/g
,
''
).
trim
().
toLowerCase
();
return
this
.
extensionsWorkbenchService
.
queryLocal
()
.
then
(
result
=>
result
.
sort
((
e1
,
e2
)
=>
e1
.
displayName
.
localeCompare
(
e2
.
displayName
)))
.
then
(
extensions
=>
extensions
.
filter
(
extension
=>
extension
.
outdated
&&
extension
.
name
.
toLowerCase
().
indexOf
(
value
)
>
-
1
))
.
then
(
result
=>
new
PagedModel
(
result
));
const
local
=
await
this
.
extensionsWorkbenchService
.
queryLocal
();
const
result
=
local
.
sort
((
e1
,
e2
)
=>
e1
.
displayName
.
localeCompare
(
e2
.
displayName
))
.
filter
(
extension
=>
extension
.
outdated
&&
extension
.
name
.
toLowerCase
().
indexOf
(
value
)
>
-
1
);
return
new
PagedModel
(
result
);
}
if
(
/@disabled/i
.
test
(
value
))
{
value
=
value
.
replace
(
/@disabled/g
,
''
).
trim
().
toLowerCase
();
return
this
.
extensionsWorkbenchService
.
queryLocal
()
.
then
(
result
=>
result
.
sort
((
e1
,
e2
)
=>
e1
.
displayName
.
localeCompare
(
e2
.
displayName
)))
.
then
(
result
=>
this
.
extensionService
.
getExtensions
()
.
then
(
runningExtensions
=>
result
.
filter
(
e
=>
runningExtensions
.
every
(
r
=>
!
areSameExtensions
(
r
,
e
))
&&
e
.
name
.
toLowerCase
().
indexOf
(
value
)
>
-
1
)))
.
then
(
result
=>
new
PagedModel
(
result
));
const
local
=
await
this
.
extensionsWorkbenchService
.
queryLocal
();
const
runningExtensions
=
await
this
.
extensionService
.
getExtensions
();
const
result
=
local
.
sort
((
e1
,
e2
)
=>
e1
.
displayName
.
localeCompare
(
e2
.
displayName
))
.
filter
(
e
=>
runningExtensions
.
every
(
r
=>
!
areSameExtensions
(
r
,
e
))
&&
e
.
name
.
toLowerCase
().
indexOf
(
value
)
>
-
1
);
return
new
PagedModel
(
result
);
}
const
query
=
Query
.
parse
(
value
);
...
...
@@ -287,7 +296,7 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
return
this
.
getRecommendationsModel
(
query
,
options
);
}
const
pagers
:
TPromise
<
IPager
<
IExtension
>>
[]
=
[];
const
pager
Promise
s
:
TPromise
<
IPager
<
IExtension
>>
[]
=
[];
let
text
=
query
.
value
;
const
extensionRegex
=
/
\b
ext:
([^\s]
+
)\b
/g
;
...
...
@@ -311,7 +320,7 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
if
(
names
.
length
)
{
const
namesOptions
=
assign
({},
options
,
{
names
});
pagers
.
push
(
this
.
extensionsWorkbenchService
.
queryGallery
(
namesOptions
));
pager
Promise
s
.
push
(
this
.
extensionsWorkbenchService
.
queryGallery
(
namesOptions
));
}
}
...
...
@@ -319,12 +328,12 @@ export class ExtensionsViewlet extends Viewlet implements IExtensionsViewlet {
options
=
assign
(
options
,
{
text
:
text
.
substr
(
0
,
350
)
});
}
pagers
.
push
(
this
.
extensionsWorkbenchService
.
queryGallery
(
options
));
pager
Promise
s
.
push
(
this
.
extensionsWorkbenchService
.
queryGallery
(
options
));
return
TPromise
.
join
(
pagers
).
then
(
pagers
=>
{
const
pager
=
pagers
.
length
===
2
?
mergePagers
(
pagers
[
0
],
pagers
[
1
])
:
pagers
[
0
];
return
new
PagedModel
(
pager
);
}
);
const
pagers
=
await
TPromise
.
join
(
pagerPromises
);
const
pager
=
pagers
.
length
===
2
?
mergePagers
(
pagers
[
0
],
pagers
[
1
])
:
pagers
[
0
];
return
new
PagedModel
(
pager
);
}
private
getRecommendationsModel
(
query
:
Query
,
options
:
IQueryOptions
):
TPromise
<
IPagedModel
<
IExtension
>>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录