提交 dafad662 编写于 作者: C CyrusNajmabadi

Move method off of CompletionHelper.

上级 ea779ae5
......@@ -375,46 +375,6 @@ private static bool TextTypedSoFarMatchesItem(CompletionItem item, char ch, stri
item.FilterText.StartsWith(textTypedWithChar, StringComparison.CurrentCultureIgnoreCase);
}
/// <summary>
/// Returns true if the character typed should be used to filter the specified completion
/// item. A character will be checked to see if it should filter an item. If not, it will be
/// checked to see if it should commit that item. If it does neither, then completion will
/// be dismissed.
/// </summary>
public virtual bool IsFilterCharacter(CompletionItem item, char ch, string textTypedSoFar)
{
// general rule: if the filtering text exactly matches the start of the item then it must be a filter character
if (TextTypedSoFarMatchesItem(item, ch, textTypedSoFar))
{
return false;
}
foreach (var rule in item.Rules.FilterCharacterRules)
{
switch (rule.Kind)
{
case CharacterSetModificationKind.Add:
if (rule.Characters.Contains(ch))
{
return true;
}
continue;
case CharacterSetModificationKind.Remove:
if (rule.Characters.Contains(ch))
{
return false;
}
continue;
case CharacterSetModificationKind.Replace:
return rule.Characters.Contains(ch);
}
}
return false;
}
private static StringComparison GetComparision(bool isCaseSensitive)
{
return isCaseSensitive? StringComparison.CurrentCulture: StringComparison.CurrentCultureIgnoreCase;
......
......@@ -337,11 +337,46 @@ private bool IsFilterCharacter(char ch)
return char.IsLetterOrDigit(ch);
}
var helper = GetCompletionHelper();
if (helper != null)
var filterText = GetCurrentFilterText(model, model.SelectedItem.Item);
return IsFilterCharacter(model.SelectedItem.Item, ch, filterText);
}
private static bool TextTypedSoFarMatchesItem(CompletionItem item, char ch, string textTypedSoFar)
{
var textTypedWithChar = textTypedSoFar + ch;
return item.DisplayText.StartsWith(textTypedWithChar, StringComparison.CurrentCultureIgnoreCase) ||
item.FilterText.StartsWith(textTypedWithChar, StringComparison.CurrentCultureIgnoreCase);
}
private bool IsFilterCharacter(CompletionItem item, char ch, string filterText)
{
// general rule: if the filtering text exactly matches the start of the item then it must be a filter character
if (TextTypedSoFarMatchesItem(item, ch, textTypedSoFar: filterText))
{
var filterText = GetCurrentFilterText(model, model.SelectedItem.Item);
return helper.IsFilterCharacter(model.SelectedItem.Item, ch, filterText);
return false;
}
foreach (var rule in item.Rules.FilterCharacterRules)
{
switch (rule.Kind)
{
case CharacterSetModificationKind.Add:
if (rule.Characters.Contains(ch))
{
return true;
}
continue;
case CharacterSetModificationKind.Remove:
if (rule.Characters.Contains(ch))
{
return false;
}
continue;
case CharacterSetModificationKind.Replace:
return rule.Characters.Contains(ch);
}
}
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册