Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a50a1466
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,发现更多精彩内容 >>
提交
a50a1466
编写于
11月 07, 2017
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Include buildNumber in remote settings search query
上级
882ec13a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
49 addition
and
44 deletion
+49
-44
src/vs/workbench/parts/preferences/browser/preferencesSearch.ts
.../workbench/parts/preferences/browser/preferencesSearch.ts
+49
-44
未找到文件。
src/vs/workbench/parts/preferences/browser/preferencesSearch.ts
浏览文件 @
a50a1466
...
...
@@ -52,7 +52,7 @@ export class PreferencesSearchProvider {
}
startSearch
(
filter
:
string
,
remote
:
boolean
):
PreferencesSearchModel
{
return
new
PreferencesSearchModel
(
this
,
filter
,
remote
);
return
new
PreferencesSearchModel
(
this
,
filter
,
remote
,
this
.
environmentService
);
}
}
...
...
@@ -60,11 +60,11 @@ export class PreferencesSearchModel {
private
_localProvider
:
LocalSearchProvider
;
private
_remoteProvider
:
RemoteSearchProvider
;
constructor
(
private
provider
:
PreferencesSearchProvider
,
private
filter
:
string
,
remote
:
boolean
)
{
constructor
(
private
provider
:
PreferencesSearchProvider
,
private
filter
:
string
,
remote
:
boolean
,
environmentService
:
IEnvironmentService
)
{
this
.
_localProvider
=
new
LocalSearchProvider
(
filter
);
if
(
remote
&&
filter
)
{
this
.
_remoteProvider
=
new
RemoteSearchProvider
(
filter
,
this
.
provider
.
endpoint
);
this
.
_remoteProvider
=
new
RemoteSearchProvider
(
filter
,
this
.
provider
.
endpoint
,
environmentService
);
}
}
...
...
@@ -109,9 +109,9 @@ class RemoteSearchProvider {
private
_filter
:
string
;
private
_remoteSearchP
:
TPromise
<
IFilterMetadata
>
;
constructor
(
filter
:
string
,
endpoint
:
IEndpointDetails
)
{
constructor
(
filter
:
string
,
endpoint
:
IEndpointDetails
,
private
environmentService
:
IEnvironmentService
)
{
this
.
_filter
=
filter
;
this
.
_remoteSearchP
=
filter
?
getSettingsFromBing
(
filter
,
endpoint
)
:
TPromise
.
wrap
(
null
);
this
.
_remoteSearchP
=
filter
?
this
.
getSettingsFromBing
(
filter
,
endpoint
)
:
TPromise
.
wrap
(
null
);
}
filterPreferences
(
preferencesModel
:
ISettingsEditorModel
):
TPromise
<
IFilterResult
>
{
...
...
@@ -139,47 +139,47 @@ class RemoteSearchProvider {
}
});
}
}
function
getSettingsFromBing
(
filter
:
string
,
endpoint
:
IEndpointDetails
):
TPromise
<
IFilterMetadata
>
{
const
url
=
prepareUrl
(
filter
,
endpoint
);
console
.
log
(
'
fetching:
'
+
url
);
const
start
=
Date
.
now
();
const
p
=
fetch
(
url
,
{
headers
:
new
Headers
({
'
User-Agent
'
:
'
request
'
,
'
Content-Type
'
:
'
application/json; charset=utf-8
'
,
'
api-key
'
:
endpoint
.
key
private
getSettingsFromBing
(
filter
:
string
,
endpoint
:
IEndpointDetails
):
TPromise
<
IFilterMetadata
>
{
const
url
=
prepareUrl
(
filter
,
endpoint
,
this
.
environmentService
.
settingsSearchBuildId
);
console
.
log
(
'
fetching:
'
+
url
);
const
start
=
Date
.
now
();
const
p
=
fetch
(
url
,
{
headers
:
new
Headers
({
'
User-Agent
'
:
'
request
'
,
'
Content-Type
'
:
'
application/json; charset=utf-8
'
,
'
api-key
'
:
endpoint
.
key
})
})
})
.
then
(
r
=>
r
.
json
())
.
then
(
result
=>
{
const
timestamp
=
Date
.
now
();
const
duration
=
timestamp
-
start
;
console
.
log
(
'
time:
'
+
duration
/
1000
);
const
suggestions
=
(
result
.
value
||
[])
.
map
(
r
=>
({
name
:
r
.
setting
||
r
.
Setting
,
score
:
r
[
'
@search.score
'
]
}));
const
scoredResults
=
Object
.
create
(
null
);
suggestions
.
forEach
(
s
=>
{
const
name
=
s
.
name
.
replace
(
/^"/
,
''
)
.
replace
(
/"$/
,
''
);
scoredResults
[
name
]
=
s
.
score
;
.
then
(
r
=>
r
.
json
())
.
then
(
result
=>
{
const
timestamp
=
Date
.
now
();
const
duration
=
timestamp
-
start
;
console
.
log
(
'
time:
'
+
duration
/
1000
);
const
suggestions
=
(
result
.
value
||
[])
.
map
(
r
=>
({
name
:
r
.
setting
||
r
.
Setting
,
score
:
r
[
'
@search.score
'
]
}));
const
scoredResults
=
Object
.
create
(
null
);
suggestions
.
forEach
(
s
=>
{
const
name
=
s
.
name
.
replace
(
/^"/
,
''
)
.
replace
(
/"$/
,
''
);
scoredResults
[
name
]
=
s
.
score
;
});
return
<
IFilterMetadata
>
{
remoteUrl
:
url
,
duration
,
timestamp
,
scoredResults
};
});
return
<
IFilterMetadata
>
{
remoteUrl
:
url
,
duration
,
timestamp
,
scoredResults
};
});
return
TPromise
.
as
(
p
as
any
);
return
TPromise
.
as
(
p
as
any
);
}
}
const
API_VERSION
=
'
api-version=2016-09-01-Preview
'
;
...
...
@@ -193,7 +193,7 @@ function escapeSpecialChars(query: string): string {
.
trim
();
}
function
prepareUrl
(
query
:
string
,
endpoint
:
IEndpointDetails
):
string
{
function
prepareUrl
(
query
:
string
,
endpoint
:
IEndpointDetails
,
buildNumber
:
number
):
string
{
query
=
escapeSpecialChars
(
query
);
const
boost
=
endpoint
.
boost
||
1
;
const
userQuery
=
`(
${
query
}
)^
${
boost
}
`
;
...
...
@@ -201,7 +201,12 @@ function prepareUrl(query: string, endpoint: IEndpointDetails): string {
// Appending Fuzzy after each word.
query
=
query
.
replace
(
/
\
+/g
,
'
~
'
)
+
'
~
'
;
return
`
${
endpoint
.
urlBase
}
?
${
API_VERSION
}
&search=
${
encodeURIComponent
(
userQuery
+
'
||
'
+
query
)}
&
${
QUERY_TYPE
}
&
${
SCORING_PROFILE
}
`
;
let
url
=
`
${
endpoint
.
urlBase
}
?
${
API_VERSION
}
&search=
${
encodeURIComponent
(
userQuery
+
'
||
'
+
query
)}
&
${
QUERY_TYPE
}
&
${
SCORING_PROFILE
}
`
;
if
(
buildNumber
)
{
url
+=
`&$filter startbuildno le
${
buildNumber
}
and endbuildno ge
${
buildNumber
}
`
;
}
return
url
;
}
class
SettingMatches
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录