Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
62fd6577
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,发现更多精彩内容 >>
提交
62fd6577
编写于
1月 22, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use POST request for settings search
上级
40497053
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
45 addition
and
25 deletion
+45
-25
src/vs/workbench/parts/preferences/electron-browser/preferencesSearch.ts
...h/parts/preferences/electron-browser/preferencesSearch.ts
+45
-25
未找到文件。
src/vs/workbench/parts/preferences/electron-browser/preferencesSearch.ts
浏览文件 @
62fd6577
...
...
@@ -19,6 +19,7 @@ import { IRequestService } from 'vs/platform/request/node/request';
import
{
asJson
}
from
'
vs/base/node/request
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IExtensionManagementService
,
LocalExtensionType
,
ILocalExtension
}
from
'
vs/platform/extensionManagement/common/extensionManagement
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
export
interface
IEndpointDetails
{
urlBase
:
string
;
...
...
@@ -120,6 +121,7 @@ export class RemoteSearchProvider implements ISearchProvider {
constructor
(
filter
:
string
,
private
endpoint
:
IEndpointDetails
,
private
installedExtensions
:
TPromise
<
ILocalExtension
[]
>
,
private
newExtensionsOnly
:
boolean
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IRequestService
private
requestService
:
IRequestService
,
@
ILogService
private
logService
:
ILogService
)
{
this
.
_filter
=
filter
;
...
...
@@ -168,9 +170,14 @@ export class RemoteSearchProvider implements ISearchProvider {
private
getSettingsFromBing
(
filter
:
string
):
TPromise
<
IFilterMetadata
>
{
const
start
=
Date
.
now
();
return
this
.
prepareUrl
(
filter
).
then
(
url
=>
{
return
this
.
prepareRequest
(
filter
).
then
(
details
=>
{
this
.
logService
.
debug
(
`Searching settings via
${
details
.
url
}
`
);
this
.
logService
.
debug
(
`Body:
${
details
.
body
}
`
);
return
this
.
requestService
.
request
({
url
,
type
:
'
POST
'
,
url
:
details
.
url
,
data
:
details
.
body
,
headers
:
{
'
User-Agent
'
:
'
request
'
,
'
Content-Type
'
:
'
application/json; charset=utf-8
'
,
...
...
@@ -179,7 +186,7 @@ export class RemoteSearchProvider implements ISearchProvider {
timeout
:
5000
}).
then
(
context
=>
{
if
(
context
.
res
.
statusCode
>=
300
)
{
throw
new
Error
(
`
${
url
}
returned status code:
${
context
.
res
.
statusCode
}
`
);
throw
new
Error
(
`
${
details
}
returned status code:
${
context
.
res
.
statusCode
}
`
);
}
return
asJson
(
context
);
...
...
@@ -201,7 +208,7 @@ export class RemoteSearchProvider implements ISearchProvider {
});
return
<
IFilterMetadata
>
{
remoteUrl
:
url
,
remoteUrl
:
details
.
url
,
// telemetry for filter text?
duration
,
timestamp
,
scoredResults
,
...
...
@@ -223,7 +230,7 @@ export class RemoteSearchProvider implements ISearchProvider {
};
}
private
prepareUrl
(
query
:
string
):
TPromise
<
string
>
{
private
async
prepareRequest
(
query
:
string
):
TPromise
<
{
url
:
string
,
body
?:
string
}
>
{
query
=
escapeSpecialChars
(
query
);
const
boost
=
10
;
const
userQuery
=
`(
${
query
}
)^
${
boost
}
`
;
...
...
@@ -237,16 +244,24 @@ export class RemoteSearchProvider implements ISearchProvider {
const
buildNumber
=
this
.
environmentService
.
settingsSearchBuildId
;
if
(
this
.
endpoint
.
key
)
{
url
+=
`
${
API_VERSION
}
&
${
QUERY_TYPE
}
`
;
url
+=
`&search=
${
encodedQuery
}
`
;
}
if
(
this
.
newExtensionsOnly
)
{
return
TPromise
.
wrap
(
url
);
}
else
{
return
this
.
getVersionAndExtensionFilters
(
buildNumber
).
then
(
filters
=>
{
url
+=
`&$filter=
${
filters
.
join
(
'
or
'
)}
`
;
return
url
;
const
usePost
=
true
;
if
(
usePost
)
{
const
filters
=
this
.
newExtensionsOnly
?
[
`diminish eq 'latest'`
]
:
await
this
.
getVersionFilters
(
buildNumber
);
const
filterStr
=
encodeURIComponent
(
filters
.
join
(
'
or
'
));
const
body
=
JSON
.
stringify
({
query
:
encodedQuery
,
filters
:
filterStr
});
}
return
{
url
,
body
};
}
else
{
url
+=
`query=
${
encodedQuery
}
`
;
...
...
@@ -255,20 +270,15 @@ export class RemoteSearchProvider implements ISearchProvider {
}
}
return
TPromise
.
wrap
(
url
);
return
TPromise
.
wrap
(
{
url
}
);
}
private
getVersion
AndExtension
Filters
(
buildNumber
?:
number
):
TPromise
<
string
[]
>
{
private
getVersionFilters
(
buildNumber
?:
number
):
TPromise
<
string
[]
>
{
return
this
.
installedExtensions
.
then
(
exts
=>
{
const
filters
=
exts
.
map
(
ext
=>
{
const
uuid
=
ext
.
identifier
.
uuid
;
const
versionString
=
ext
.
manifest
.
version
.
split
(
'
.
'
)
.
map
(
versionPart
=>
strings
.
pad
(
<
any
>
versionPart
,
10
))
.
join
(
''
);
return
`(packageid eq '
${
uuid
}
' and startbuildno le '
${
versionString
}
' and endbuildno ge '
${
versionString
}
')`
;
});
// Only search extensions that contribute settings
const
filters
=
exts
.
filter
(
ext
=>
ext
.
manifest
.
contributes
&&
ext
.
manifest
.
contributes
.
configuration
)
.
map
(
ext
=>
this
.
getExtensionFilter
(
ext
));
if
(
buildNumber
)
{
filters
.
push
(
`(packageid eq 'core' and startbuildno le '
${
buildNumber
}
' and endbuildno ge '
${
buildNumber
}
')`
);
...
...
@@ -277,6 +287,16 @@ export class RemoteSearchProvider implements ISearchProvider {
return
filters
;
});
}
private
getExtensionFilter
(
ext
:
ILocalExtension
):
string
{
const
uuid
=
ext
.
identifier
.
uuid
;
const
versionString
=
ext
.
manifest
.
version
.
split
(
'
.
'
)
.
map
(
versionPart
=>
strings
.
pad
(
<
any
>
versionPart
,
10
))
.
join
(
''
);
return
`(packageid eq '
${
uuid
}
' and startbuildno le '
${
versionString
}
' and endbuildno ge '
${
versionString
}
')`
;
}
}
const
API_VERSION
=
'
api-version=2016-09-01-Preview
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录