diff --git a/src/EditorFeatures/Core/Extensibility/Completion/CompletionHelper.cs b/src/EditorFeatures/Core/Extensibility/Completion/CompletionHelper.cs
index 59b413f86292157f1754f0e72563969f893b1995..a9556b09a1b9f4255601efb425a090fd3986d4f8 100644
--- a/src/EditorFeatures/Core/Extensibility/Completion/CompletionHelper.cs
+++ b/src/EditorFeatures/Core/Extensibility/Completion/CompletionHelper.cs
@@ -117,8 +117,8 @@ protected static bool IsAllDigits(string filterText)
protected PatternMatch? GetMatch(CompletionItem item, string filterText, bool includeMatchSpans)
{
- var patternMatcher = this.GetPatternMatcher(GetCultureSpecificQuirks(filterText), CultureInfo.CurrentCulture);
- var match = patternMatcher.GetFirstMatch(GetCultureSpecificQuirks(item.FilterText), includeMatchSpans);
+ var patternMatcher = this.GetPatternMatcher(filterText, CultureInfo.CurrentCulture);
+ var match = patternMatcher.GetFirstMatch(item.FilterText, includeMatchSpans);
if (match != null)
{
@@ -128,8 +128,8 @@ protected static bool IsAllDigits(string filterText)
// Start with the culture-specific comparison, and fall back to en-US.
if (!CultureInfo.CurrentCulture.Equals(EnUSCultureInfo))
{
- patternMatcher = this.GetFallbackPatternMatcher(GetCultureSpecificQuirks(filterText));
- match = patternMatcher.GetFirstMatch(GetCultureSpecificQuirks(item.FilterText));
+ patternMatcher = this.GetEnUSPatternMatcher(filterText);
+ match = patternMatcher.GetFirstMatch(item.FilterText);
if (match != null)
{
return match;
@@ -139,52 +139,37 @@ protected static bool IsAllDigits(string filterText)
return null;
}
- ///
- /// Apply any culture-specific quirks to the given text for the purposes of pattern matching.
- /// For example, in the Turkish locale, capital 'i's should be treated specially in Visual Basic.
- ///
- protected virtual string GetCultureSpecificQuirks(string candidate)
- {
- return candidate;
- }
-
private readonly object _gate = new object();
private readonly Dictionary _patternMatcherMap = new Dictionary();
private readonly Dictionary _fallbackPatternMatcherMap = new Dictionary();
internal static readonly CultureInfo EnUSCultureInfo = new CultureInfo("en-US");
- protected PatternMatcher GetPatternMatcher(string value, CultureInfo culture)
+ private PatternMatcher GetPatternMatcher(
+ string value, CultureInfo culture, Dictionary map)
{
lock (_gate)
{
PatternMatcher patternMatcher;
- if (!_patternMatcherMap.TryGetValue(value, out patternMatcher))
+ if (!map.TryGetValue(value, out patternMatcher))
{
- patternMatcher = new PatternMatcher(value, culture,
- verbatimIdentifierPrefixIsWordCharacter: true,
+ patternMatcher = new PatternMatcher(value, culture,
+ verbatimIdentifierPrefixIsWordCharacter: true,
allowFuzzyMatching: false);
- _patternMatcherMap.Add(value, patternMatcher);
+ map.Add(value, patternMatcher);
}
return patternMatcher;
}
}
- private PatternMatcher GetFallbackPatternMatcher(string value)
+ protected PatternMatcher GetPatternMatcher(string value, CultureInfo culture)
{
- lock (_gate)
- {
- PatternMatcher patternMatcher;
- if (!_fallbackPatternMatcherMap.TryGetValue(value, out patternMatcher))
- {
- patternMatcher = new PatternMatcher(
- value, EnUSCultureInfo, verbatimIdentifierPrefixIsWordCharacter: true,
- allowFuzzyMatching: false);
- _fallbackPatternMatcherMap.Add(value, patternMatcher);
- }
+ return GetPatternMatcher(value, culture, _patternMatcherMap);
+ }
- return patternMatcher;
- }
+ private PatternMatcher GetEnUSPatternMatcher(string value)
+ {
+ return GetPatternMatcher(value, EnUSCultureInfo, _fallbackPatternMatcherMap);
}
///
@@ -193,8 +178,8 @@ private PatternMatcher GetFallbackPatternMatcher(string value)
///
public virtual bool IsBetterFilterMatch(CompletionItem item1, CompletionItem item2, string filterText, CompletionTrigger trigger, CompletionFilterReason filterReason, ImmutableArray recentItems = default(ImmutableArray))
{
- var match1 = GetMatch(item1, GetCultureSpecificQuirks(filterText));
- var match2 = GetMatch(item2, GetCultureSpecificQuirks(filterText));
+ var match1 = GetMatch(item1, filterText);
+ var match2 = GetMatch(item2, filterText);
if (match1 != null && match2 != null)
{
diff --git a/src/EditorFeatures/VisualBasic/Completion/VisualBasicCompletionHelper.vb b/src/EditorFeatures/VisualBasic/Completion/VisualBasicCompletionHelper.vb
index 5924ec733076d7c72886a173e07d47318d569444..3001a51d45f6b96b61548373519be31f4b4318f2 100644
--- a/src/EditorFeatures/VisualBasic/Completion/VisualBasicCompletionHelper.vb
+++ b/src/EditorFeatures/VisualBasic/Completion/VisualBasicCompletionHelper.vb
@@ -52,15 +52,6 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.Completion
Return MyBase.MatchesFilterText(item, filterText, trigger, filterReason, recentItems)
End Function
- Protected Overrides Function GetCultureSpecificQuirks(candidate As String) As String
- ' TODO: define way to identify this case w/o language specific check
- If CultureInfo.CurrentCulture.Name = "tr-TR" Then
- Return candidate.Replace("I"c, "İ"c)
- End If
-
- Return candidate
- End Function
-
Public Overrides Function IsBetterFilterMatch(item1 As CompletionItem, item2 As CompletionItem, filterText As String, trigger As CompletionTrigger, filterReason As CompletionFilterReason, Optional recentItems As ImmutableArray(Of String) = Nothing) As Boolean
If filterReason = CompletionFilterReason.BackspaceOrDelete Then