Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
2fa7b6e8
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,发现更多精彩内容 >>
提交
2fa7b6e8
编写于
3月 19, 2017
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Highlight the DisplayText and not the FilterText when highlighting completion items.
上级
96e59f06
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
47 addition
and
49 deletion
+47
-49
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller.Session_FilterModel.cs
...IntelliSense/Completion/Controller.Session_FilterModel.cs
+5
-1
src/EditorFeatures/Next/IntelliSense/Completion/Presentation/Roslyn15CompletionSet.cs
...lliSense/Completion/Presentation/Roslyn15CompletionSet.cs
+14
-12
src/Features/Core/Portable/Completion/CompletionHelper.cs
src/Features/Core/Portable/Completion/CompletionHelper.cs
+28
-36
未找到文件。
src/EditorFeatures/Core/Implementation/IntelliSense/Completion/Controller.Session_FilterModel.cs
浏览文件 @
2fa7b6e8
...
...
@@ -480,7 +480,11 @@ private bool IsBetterDeletionMatch(FilterResult result1, FilterResult result2)
}
}
return
helper
.
MatchesFilterText
(
item
,
filterText
,
CultureInfo
.
CurrentCulture
);
// Checks if the given completion item matches the pattern provided so far.
// A completion item is checked against the pattern by see if it's
// CompletionItem.FilterText matches the item. That way, the pattern it checked
// against terms like "IList" and not IList<>
return
helper
.
MatchesPattern
(
item
.
FilterText
,
filterText
,
CultureInfo
.
CurrentCulture
);
}
private
static
int
GetRecentItemIndex
(
ImmutableArray
<
string
>
recentItems
,
CompletionItem
item
)
...
...
src/EditorFeatures/Next/IntelliSense/Completion/Presentation/Roslyn15CompletionSet.cs
浏览文件 @
2fa7b6e8
using
System.Collections.Generic
;
// 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
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Globalization
;
using
System.Linq
;
...
...
@@ -71,22 +73,22 @@ private CompletionHelper GetCompletionHelper()
public
IReadOnlyList
<
Span
>
GetHighlightedSpansInDisplayText
(
string
displayText
)
{
if
(
_highlightMatchingPortions
&&
!
string
.
IsNullOrWhiteSpace
(
FilterText
))
if
(
SuggestionModeItem
!=
null
&&
SuggestionModeItem
.
DisplayText
==
displayText
)
{
// Don't highlight the builder-completion-item.
return
null
;
}
var
pattern
=
this
.
FilterText
;
if
(
_highlightMatchingPortions
&&
!
string
.
IsNullOrWhiteSpace
(
pattern
))
{
var
completionHelper
=
this
.
GetCompletionHelper
();
if
(
completionHelper
!=
null
)
{
var
completionItem
=
this
.
CompletionItemMap
.
Keys
.
FirstOrDefault
(
k
=>
k
.
DisplayText
==
displayText
);
if
(
completionItem
!=
null
&&
completionItem
!=
SuggestionModeItem
)
{
var
highlightedSpans
=
completionHelper
.
GetHighlightedSpans
(
completionItem
,
FilterText
,
CultureInfo
.
CurrentCulture
);
if
(
highlightedSpans
!=
null
)
{
return
highlightedSpans
.
Select
(
s
=>
s
.
ToSpan
()).
ToArray
();
}
}
displayText
,
pattern
,
CultureInfo
.
CurrentCulture
);
return
highlightedSpans
.
SelectAsArray
(
s
=>
s
.
ToSpan
());
}
}
...
...
src/Features/Core/Portable/Completion/CompletionHelper.cs
浏览文件 @
2fa7b6e8
...
...
@@ -6,7 +6,6 @@
using
System.Globalization
;
using
Microsoft.CodeAnalysis.LanguageServices
;
using
Microsoft.CodeAnalysis.PatternMatching
;
using
Microsoft.CodeAnalysis.Shared.Utilities
;
using
Microsoft.CodeAnalysis.Text
;
namespace
Microsoft.CodeAnalysis.Completion
...
...
@@ -49,42 +48,39 @@ public static CompletionHelper GetHelper(Document document)
}
public
ImmutableArray
<
TextSpan
>
GetHighlightedSpans
(
CompletionItem
completionItem
,
string
filterText
,
CultureInfo
culture
)
string
text
,
string
pattern
,
CultureInfo
culture
)
{
var
match
=
GetMatch
(
completionItem
,
filterText
,
includeMatchSpans
:
true
,
culture
:
culture
);
// Use the display text of the completion item
var
match
=
GetMatch
(
text
,
pattern
,
includeMatchSpans
:
true
,
culture
:
culture
);
return
match
==
null
?
ImmutableArray
<
TextSpan
>.
Empty
:
match
.
Value
.
MatchedSpans
;
}
/// <summary>
/// Returns true if the completion item matches the
filter text typed
so far. Returns 'true'
/// Returns true if the completion item matches the
pattern
so far. Returns 'true'
/// iff the completion item matches and should be included in the filtered completion
/// results, or false if it should not be.
/// </summary>
public
bool
MatchesFilterText
(
CompletionItem
item
,
string
filterText
,
CultureInfo
culture
)
{
return
GetMatch
(
item
,
filterText
,
culture
)
!=
null
;
}
public
bool
MatchesPattern
(
string
text
,
string
pattern
,
CultureInfo
culture
)
=>
GetMatch
(
text
,
pattern
,
culture
)
!=
null
;
private
PatternMatch
?
GetMatch
(
CompletionItem
item
,
string
filterText
,
CultureInfo
culture
)
{
return
GetMatch
(
item
,
filterText
,
includeMatchSpans
:
false
,
culture
:
culture
);
}
private
PatternMatch
?
GetMatch
(
string
text
,
string
pattern
,
CultureInfo
culture
)
=>
GetMatch
(
text
,
pattern
,
includeMatchSpans
:
false
,
culture
:
culture
);
private
PatternMatch
?
GetMatch
(
CompletionItem
item
,
string
filterText
,
string
completionItemText
,
string
pattern
,
bool
includeMatchSpans
,
CultureInfo
culture
)
{
// If the item has a dot in it (i.e. for something like enum completion), then attempt
// to match what the user wrote against the last portion of the name. That way if they
// write "Bl" and we have "Blub" and "Color.Black", we'll consider
ht
e latter to be a
// write "Bl" and we have "Blub" and "Color.Black", we'll consider
th
e latter to be a
// better match as they'll both be prefix matches, and the latter will have a higher
// priority.
var
lastDotIndex
=
item
.
Filter
Text
.
LastIndexOf
(
'.'
);
var
lastDotIndex
=
completionItem
Text
.
LastIndexOf
(
'.'
);
if
(
lastDotIndex
>=
0
)
{
var
textAfterLastDot
=
item
.
Filter
Text
.
Substring
(
lastDotIndex
+
1
);
var
match
=
GetMatchWorker
(
textAfterLastDot
,
filterText
,
includeMatchSpans
,
culture
);
var
textAfterLastDot
=
completionItem
Text
.
Substring
(
lastDotIndex
+
1
);
var
match
=
GetMatchWorker
(
textAfterLastDot
,
pattern
,
includeMatchSpans
,
culture
);
if
(
match
!=
null
)
{
return
match
;
...
...
@@ -93,14 +89,14 @@ public bool MatchesFilterText(CompletionItem item, string filterText, CultureInf
// Didn't have a dot, or the user text didn't match the portion after the dot.
// Just do a normal check against the entire completion item.
return
GetMatchWorker
(
item
.
FilterText
,
filterText
,
includeMatchSpans
,
culture
);
return
GetMatchWorker
(
completionItemText
,
pattern
,
includeMatchSpans
,
culture
);
}
private
PatternMatch
?
GetMatchWorker
(
string
completionItemText
,
string
filterText
,
string
completionItemText
,
string
pattern
,
bool
includeMatchSpans
,
CultureInfo
culture
)
{
var
patternMatcher
=
this
.
GetPatternMatcher
(
filterText
,
culture
);
var
patternMatcher
=
this
.
GetPatternMatcher
(
pattern
,
culture
);
var
match
=
patternMatcher
.
GetFirstMatch
(
completionItemText
,
includeMatchSpans
);
if
(
match
!=
null
)
...
...
@@ -111,7 +107,7 @@ public bool MatchesFilterText(CompletionItem item, string filterText, CultureInf
// Start with the culture-specific comparison, and fall back to en-US.
if
(!
culture
.
Equals
(
EnUSCultureInfo
))
{
patternMatcher
=
this
.
GetEnUSPatternMatcher
(
filterText
);
patternMatcher
=
this
.
GetEnUSPatternMatcher
(
pattern
);
match
=
patternMatcher
.
GetFirstMatch
(
completionItemText
);
if
(
match
!=
null
)
{
...
...
@@ -123,7 +119,7 @@ public bool MatchesFilterText(CompletionItem item, string filterText, CultureInf
}
private
PatternMatcher
GetPatternMatcher
(
string
value
,
CultureInfo
culture
,
Dictionary
<
CultureInfo
,
Dictionary
<
string
,
PatternMatcher
>>
map
)
string
pattern
,
CultureInfo
culture
,
Dictionary
<
CultureInfo
,
Dictionary
<
string
,
PatternMatcher
>>
map
)
{
lock
(
_gate
)
{
...
...
@@ -133,36 +129,32 @@ public bool MatchesFilterText(CompletionItem item, string filterText, CultureInf
map
[
culture
]
=
innerMap
;
}
if
(!
innerMap
.
TryGetValue
(
value
,
out
var
patternMatcher
))
if
(!
innerMap
.
TryGetValue
(
pattern
,
out
var
patternMatcher
))
{
patternMatcher
=
new
PatternMatcher
(
value
,
culture
,
patternMatcher
=
new
PatternMatcher
(
pattern
,
culture
,
verbatimIdentifierPrefixIsWordCharacter
:
true
,
allowFuzzyMatching
:
false
);
innerMap
.
Add
(
value
,
patternMatcher
);
innerMap
.
Add
(
pattern
,
patternMatcher
);
}
return
patternMatcher
;
}
}
private
PatternMatcher
GetPatternMatcher
(
string
value
,
CultureInfo
culture
)
{
return
GetPatternMatcher
(
value
,
culture
,
_patternMatcherMap
);
}
private
PatternMatcher
GetPatternMatcher
(
string
pattern
,
CultureInfo
culture
)
=>
GetPatternMatcher
(
pattern
,
culture
,
_patternMatcherMap
);
private
PatternMatcher
GetEnUSPatternMatcher
(
string
value
)
{
return
GetPatternMatcher
(
value
,
EnUSCultureInfo
,
_fallbackPatternMatcherMap
);
}
private
PatternMatcher
GetEnUSPatternMatcher
(
string
pattern
)
=>
GetPatternMatcher
(
pattern
,
EnUSCultureInfo
,
_fallbackPatternMatcherMap
);
/// <summary>
/// Returns true if item1 is a better completion item than item2 given the provided filter
/// text, or false if it is not better.
/// </summary>
public
int
CompareItems
(
CompletionItem
item1
,
CompletionItem
item2
,
string
filterText
,
CultureInfo
culture
)
public
int
CompareItems
(
CompletionItem
item1
,
CompletionItem
item2
,
string
pattern
,
CultureInfo
culture
)
{
var
match1
=
GetMatch
(
item1
,
filterText
,
culture
);
var
match2
=
GetMatch
(
item2
,
filterText
,
culture
);
var
match1
=
GetMatch
(
item1
.
FilterText
,
pattern
,
culture
);
var
match2
=
GetMatch
(
item2
.
FilterText
,
pattern
,
culture
);
if
(
match1
!=
null
&&
match2
!=
null
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录