Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ee0640b8
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,发现更多精彩内容 >>
提交
ee0640b8
编写于
6月 13, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use first instead of sequence to pick best occurences
上级
d949b01b
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
6 addition
and
25 deletion
+6
-25
src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts
src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts
+6
-25
未找到文件。
src/vs/editor/contrib/wordHighlighter/wordHighlighter.ts
浏览文件 @
ee0640b8
...
@@ -2,11 +2,10 @@
...
@@ -2,11 +2,10 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
sequence
,
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
asWinJsPromise
,
first
}
from
'
vs/base/common/async
'
;
import
{
onUnexpectedExternalError
}
from
'
vs/base/common/errors
'
;
import
{
onUnexpectedExternalError
}
from
'
vs/base/common/errors
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
...
@@ -23,7 +22,7 @@ import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/cont
...
@@ -23,7 +22,7 @@ import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/cont
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
firstIndex
}
from
'
vs/base/common/arrays
'
;
import
{
firstIndex
,
isFalsyOrEmpty
}
from
'
vs/base/common/arrays
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ITextModel
,
TrackedRangeStickiness
,
OverviewRulerLane
,
IModelDeltaDecoration
}
from
'
vs/editor/common/model
'
;
import
{
ITextModel
,
TrackedRangeStickiness
,
OverviewRulerLane
,
IModelDeltaDecoration
}
from
'
vs/editor/common/model
'
;
...
@@ -40,32 +39,14 @@ export const ctxHasWordHighlights = new RawContextKey<boolean>('hasWordHighlight
...
@@ -40,32 +39,14 @@ export const ctxHasWordHighlights = new RawContextKey<boolean>('hasWordHighlight
export
function
getOccurrencesAtPosition
(
model
:
ITextModel
,
position
:
Position
):
TPromise
<
DocumentHighlight
[]
>
{
export
function
getOccurrencesAtPosition
(
model
:
ITextModel
,
position
:
Position
):
TPromise
<
DocumentHighlight
[]
>
{
const
orderedByScore
=
DocumentHighlightProviderRegistry
.
ordered
(
model
);
const
orderedByScore
=
DocumentHighlightProviderRegistry
.
ordered
(
model
);
let
foundResult
=
false
;
// in order of score ask the occurrences provider
// in order of score ask the occurrences provider
// until someone response with a good result
// until someone response with a good result
// (good = none empty array)
// (good = none empty array)
return
sequence
(
orderedByScore
.
map
(
provider
=>
{
return
first
(
orderedByScore
.
map
(
provider
=>
()
=>
{
return
():
TPromise
<
DocumentHighlight
[]
>
=>
{
return
asWinJsPromise
(
token
=>
provider
.
provideDocumentHighlights
(
model
,
position
,
token
))
if
(
!
foundResult
)
{
.
then
(
undefined
,
onUnexpectedExternalError
);
return
asWinJsPromise
((
token
)
=>
{
}),
result
=>
!
isFalsyOrEmpty
(
result
));
return
provider
.
provideDocumentHighlights
(
model
,
position
,
token
);
}).
then
(
data
=>
{
if
(
Array
.
isArray
(
data
)
&&
data
.
length
>
0
)
{
foundResult
=
true
;
return
data
;
}
return
undefined
;
},
err
=>
{
onUnexpectedExternalError
(
err
);
return
undefined
;
});
}
return
undefined
;
};
})).
then
(
values
=>
{
return
values
[
0
];
});
}
}
registerDefaultLanguageCommand
(
'
_executeDocumentHighlights
'
,
getOccurrencesAtPosition
);
registerDefaultLanguageCommand
(
'
_executeDocumentHighlights
'
,
getOccurrencesAtPosition
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录