Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
e0af906a
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e0af906a
编写于
8月 06, 2019
作者:
I
Ivan Basov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code review feedback
上级
b87e2db6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
36 deletion
+29
-36
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/FilterResult.cs
...plementation/IntelliSense/AsyncCompletion/FilterResult.cs
+27
-33
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs
...mplementation/IntelliSense/AsyncCompletion/ItemManager.cs
+2
-3
未找到文件。
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/FilterResult.cs
浏览文件 @
e0af906a
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using
Roslyn.Utilities
;
using
System
;
using
Microsoft.CodeAnalysis.Completion
;
using
Roslyn.Utilities
;
namespace
Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.AsyncCompletion
{
internal
struct
FilterResult
internal
struct
FilterResult
:
IComparable
<
FilterResult
>
{
public
readonly
CompletionItem
CompletionItem
;
public
readonly
bool
MatchedFilterText
;
...
...
@@ -19,50 +20,43 @@ public FilterResult(CompletionItem completionItem, string filterText, bool match
FilterText
=
filterText
;
}
public
static
int
Compare
(
FilterResult
result1
,
FilterResult
result2
)
public
int
CompareTo
(
FilterResult
other
)
{
var
item1
=
result1
.
CompletionItem
;
var
item2
=
result2
.
CompletionItem
;
var
item1
=
this
.
CompletionItem
;
var
item2
=
other
.
CompletionItem
;
var
prefixLength1
=
item1
.
FilterText
.
GetCaseInsensitivePrefixLength
(
result1
.
FilterText
);
var
prefixLength2
=
item2
.
FilterText
.
GetCaseInsensitivePrefixLength
(
result2
.
FilterText
);
var
prefixLength1
=
item1
.
FilterText
.
GetCaseInsensitivePrefixLength
(
this
.
FilterText
);
var
prefixLength2
=
item2
.
FilterText
.
GetCaseInsensitivePrefixLength
(
other
.
FilterText
);
// Prefer the item that matches a longer prefix of the filter text.
if
(
prefixLength1
!=
prefixLength2
)
{
return
prefixLength1
.
CompareTo
(
prefixLength2
);
}
else
{
// If the lengths are the same, prefer the one with the higher match priority.
// But only if it's an item that would have been hard selected. We don't want
// to aggressively select an item that was only going to be softly offered.
var
item1Priority
=
item1
.
Rules
.
SelectionBehavior
==
CompletionItemSelectionBehavior
.
HardSelection
?
item1
.
Rules
.
MatchPriority
:
MatchPriority
.
Default
;
var
item2Priority
=
item2
.
Rules
.
SelectionBehavior
==
CompletionItemSelectionBehavior
.
HardSelection
?
item2
.
Rules
.
MatchPriority
:
MatchPriority
.
Default
;
if
(
item1Priority
!=
item2Priority
)
{
return
item1Priority
>
item2Priority
?
1
:
-
1
;
}
// If the lengths are the same, prefer the one with the higher match priority.
// But only if it's an item that would have been hard selected. We don't want
// to aggressively select an item that was only going to be softly offered.
var
item1Priority
=
item1
.
Rules
.
SelectionBehavior
==
CompletionItemSelectionBehavior
.
HardSelection
?
item1
.
Rules
.
MatchPriority
:
MatchPriority
.
Default
;
var
item2Priority
=
item2
.
Rules
.
SelectionBehavior
==
CompletionItemSelectionBehavior
.
HardSelection
?
item2
.
Rules
.
MatchPriority
:
MatchPriority
.
Default
;
prefixLength1
=
item1
.
FilterText
.
GetCaseSensitivePrefixLength
(
result1
.
FilterText
);
prefixLength2
=
item2
.
FilterText
.
GetCaseSensitivePrefixLength
(
result2
.
FilterText
);
// If there are "Abc" vs "abc", we should prefer the case typed by user.
if
(
prefixLength1
!=
prefixLength2
)
{
return
prefixLength1
>
prefixLength2
?
1
:
-
1
;
}
if
(
item1Priority
!=
item2Priority
)
{
return
item1Priority
.
CompareTo
(
item2Priority
);
}
if
(
result1
.
CompletionItem
.
IsPreferredItem
()
!=
result2
.
CompletionItem
.
IsPreferredItem
())
{
return
result1
.
CompletionItem
.
IsPreferredItem
()
?
1
:
-
1
;
}
prefixLength1
=
item1
.
FilterText
.
GetCaseSensitivePrefixLength
(
this
.
FilterText
);
prefixLength2
=
item2
.
FilterText
.
GetCaseSensitivePrefixLength
(
other
.
FilterText
);
return
0
;
// If there are "Abc" vs "abc", we should prefer the case typed by user.
if
(
prefixLength1
!=
prefixLength2
)
{
return
prefixLength1
.
CompareTo
(
prefixLength2
);
}
return
this
.
CompletionItem
.
IsPreferredItem
().
CompareTo
(
other
.
CompletionItem
.
IsPreferredItem
());
}
}
}
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs
浏览文件 @
e0af906a
...
...
@@ -365,7 +365,7 @@ private static bool IsAfterDot(ITextSnapshot snapshot, ITrackingSpan applicableT
}
else
{
var
match
=
FilterResult
.
Compare
(
currentFilterResult
.
FilterResult
,
bestFilterResult
.
Value
.
FilterResult
);
var
match
=
currentFilterResult
.
FilterResult
.
CompareTo
(
bestFilterResult
.
Value
.
FilterResult
);
if
(
match
>
0
)
{
moreThanOneMatchWithSamePriority
=
false
;
...
...
@@ -540,7 +540,7 @@ internal static int GetRecentItemIndex(ImmutableArray<string> recentItems, Rosly
}
internal
static
bool
IsBetterDeletionMatch
(
FilterResult
result1
,
FilterResult
result2
)
=>
FilterResult
.
Compare
(
result1
,
result2
)
>
0
;
=>
result1
.
CompareTo
(
result2
)
>
0
;
internal
static
bool
MatchesFilterText
(
CompletionHelper
helper
,
RoslynCompletionItem
item
,
...
...
@@ -582,7 +582,6 @@ internal static bool IsBetterDeletionMatch(FilterResult result1, FilterResult re
return
helper
.
MatchesPattern
(
item
.
FilterText
,
filterText
,
CultureInfo
.
CurrentCulture
);
}
internal
static
bool
IsHardSelection
(
string
fullFilterText
,
CompletionTriggerKind
initialTriggerKind
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录