Skip to content

Commit

Permalink
Merge pull request #11739 from CyrusNajmabadi/completionFeatures
Browse files Browse the repository at this point in the history
Actually listen to completion options.
  • Loading branch information
CyrusNajmabadi committed Jun 3, 2016
2 parents 366c86e + 70cf327 commit c346e48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,14 @@ public PresentationItem GetPresentationItem(VSCompletion completion)
return null;
}

protected string GetLanguage()
protected Document GetDocument()
{
var document = SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
if (document != null)
{
return document.Project.Language;
}
return SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
}

return "";
protected string GetLanguage()
{
return GetDocument()?.Project.Language ?? "";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,33 @@ internal class Roslyn15CompletionSet : Roslyn14CompletionSet
private CompletionHelper _completionHelper;
public IReadOnlyList<IntellisenseFilter2> Filters;

private readonly bool _highlightMatchingPortions;
private readonly bool _showFilters;

public Roslyn15CompletionSet(
IVisualStudioCompletionSet vsCompletionSet,
CompletionPresenterSession completionPresenterSession,
ITextView textView,
ITextBuffer subjectBuffer)
: base(vsCompletionSet, completionPresenterSession, textView, subjectBuffer)
{
var document = GetDocument();

if (document != null)
{
var options = document.Options;
_highlightMatchingPortions = options.GetOption(CompletionOptions.HighlightMatchingPortionsOfCompletionListItems);
_showFilters = options.GetOption(CompletionOptions.ShowCompletionItemFilters);
}
}

protected override void SetupFilters(ImmutableArray<CompletionItemFilter> completionItemFilters)
{
// If more than one filter was provided, then present it to the user.
if (Filters == null && completionItemFilters.Length > 1)
if (_showFilters && Filters == null && completionItemFilters.Length > 1)
{
Filters = completionItemFilters.Select(f => new IntellisenseFilter2(this, f, GetLanguage()))
.ToArray();
.ToArray();
}
}

Expand All @@ -48,7 +59,7 @@ private CompletionHelper GetCompletionHelper()
this.AssertIsForeground();
if (_completionHelper == null)
{
var document = SubjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges();
var document = GetDocument();
if (document != null)
{
_completionHelper = CompletionHelper.GetHelper(document,
Expand All @@ -61,7 +72,7 @@ private CompletionHelper GetCompletionHelper()

public IReadOnlyList<Span> GetHighlightedSpansInDisplayText(string displayText)
{
if (CompletionItemToFilterText != null)
if (_highlightMatchingPortions && CompletionItemToFilterText != null)
{
var completionHelper = this.GetCompletionHelper();
if (completionHelper != null)
Expand Down

0 comments on commit c346e48

Please sign in to comment.