public override void SelectBestMatch() { ITextSnapshot snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; string typedText = ApplicableTo.GetText(snapshot).Trim(); if (string.IsNullOrWhiteSpace(typedText)) { if (_filteredCompletions.Any()) { SelectionStatus = new CompletionSelectionStatus(_filteredCompletions.First(), true, true); } return; } foreach (Completion comp in _filteredCompletions) { int index = comp.DisplayText.IndexOf(typedText, StringComparison.OrdinalIgnoreCase); if (index == 0) { SelectionStatus = new CompletionSelectionStatus(comp, true, true); return; } else if (index > -1) { SelectionStatus = new CompletionSelectionStatus(comp, true, true); return; } } }
/// <summary> /// Restricts the set of completions to those that match the applicability text /// of the completion set, and then determines the best match. /// </summary> public override void Filter() { if (_completions == null) { return; } if (_filteredCompletions == null) { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = true; } return; } var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); if (!string.IsNullOrEmpty(text)) { FilterToText(text); } else if (_shouldHideAdvanced) { FilterToPredicate(c => !IsAdvanced(c)); } else { FilterToPredicate(_ => true); } }
private void CreateCompletionListBuilder( RoslynCompletionItem selectedItem, RoslynCompletionItem suggestionModeItem, bool suggestionMode) { try { WritableCompletionBuilders.BeginBulkOperation(); WritableCompletionBuilders.Clear(); if (suggestionMode) { var applicableToText = ApplicableTo.GetText( ApplicableTo.TextBuffer.CurrentSnapshot); var text = applicableToText.Length > 0 ? applicableToText : suggestionModeItem.DisplayText; var vsCompletion = GetVSCompletion(suggestionModeItem, text); WritableCompletionBuilders.Add(vsCompletion); } } finally { WritableCompletionBuilders.EndBulkOperation(); } }
public override void SelectBestMatch() { base.SelectBestMatch(); var snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; var userText = ApplicableTo.GetText(snapshot); // If VS couldn't find an exact match, try again without closing quote. if (SelectionStatus.IsSelected) { return; } if (userText.Length == 0 || userText.Last() != userText[0]) { return; // If there is no closing quote, do nothing. } var originalSpan = ApplicableTo; try { var spanPoints = originalSpan.GetSpan(snapshot); ApplicableTo = snapshot.CreateTrackingSpan(spanPoints.Start, spanPoints.Length - 1, ApplicableTo.TrackingMode); base.SelectBestMatch(); } finally { ApplicableTo = originalSpan; } }
/// <summary> /// Determines and selects the only match in the completion set. /// This ignores the user's filtering preferences. /// </summary> /// <returns> /// True if a match is found and selected; otherwise, false if there /// is no single match in the completion set. /// </returns> public bool SelectSingleBest() { var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); Completion bestMatch = null; // Using the _completions field to search through all completions // and ignore filtering settings. foreach (var comp in _completions) { if (_comparer.IsCandidateMatch(comp.DisplayText, text)) { if (bestMatch == null) { bestMatch = comp; } else { return(false); } } } if (bestMatch != null) { SelectionStatus = new CompletionSelectionStatus(bestMatch, isSelected: true, isUnique: true); return(true); } else { return(false); } }
public override void Filter() { ITextSnapshot snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; string typedText = ApplicableTo.GetText(snapshot); if (!string.IsNullOrEmpty(typedText)) { List <Completion> temp = _allCompletions.Where(c => c.DisplayText.IndexOf(typedText, StringComparison.InvariantCultureIgnoreCase) > -1).ToList(); if (temp.Any()) { this.WritableCompletions.BeginBulkOperation(); this.WritableCompletions.Clear(); this.WritableCompletions.AddRange(temp); this.WritableCompletions.EndBulkOperation(); } } else { this.WritableCompletions.BeginBulkOperation(); this.WritableCompletions.Clear(); this.WritableCompletions.AddRange(_allCompletions); this.WritableCompletions.EndBulkOperation(); } }
public override void Filter() { ITextSnapshot snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; string typedText = ApplicableTo.GetText(snapshot); if (!string.IsNullOrEmpty(typedText)) { List <CrmCompletion> temp = _allCompletions.Where(c => c.IsMatch(typedText)).ToList(); if (temp.Any()) { this.WritableCompletions.BeginBulkOperation(); this.WritableCompletions.Clear(); this.WritableCompletions.AddRange(temp); this.WritableCompletions.EndBulkOperation(); } } else { this.WritableCompletions.BeginBulkOperation(); this.WritableCompletions.Clear(); this.WritableCompletions.AddRange(_allCompletions); this.WritableCompletions.EndBulkOperation(); } }
public override void Filter() { var filteredCompletions = (FilteredObservableCollection <Completion>) this.Completions; var pattern = ApplicableTo.GetText(_snapshot); filteredCompletions.Filter(c => StringPatternMatching.MatchPattern(c.InsertionText, pattern)); }
public override void SelectBestMatch() { var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); if (string.IsNullOrWhiteSpace(text)) { SelectionStatus = new CompletionSelectionStatus(null, false, false); return; } Microsoft.VisualStudio.Language.Intellisense.Completion bestMatch = null; var bestValue = 0; var isUnique = true; foreach (var completion in Completions) { int value = CompareCompletionText(completion.DisplayText, text); if (bestMatch == null || value > bestValue) { bestMatch = completion; bestValue = value; isUnique = true; } else if (value == bestValue) { isUnique = false; } } SelectionStatus = new CompletionSelectionStatus(bestMatch, bestValue > 0, isUnique); }
public override void Filter() { try { var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); text = text.TrimStart('.').Trim(' '); //if (IsNullOrWhiteSpace(text)) { // _session.Dismiss(); // return; //} var orderedByDistance = _items.Where(c => ContainsAllSymbols(text, c.InsertionText)) .OfType <MyCompletion>() .OrderBy(c => { var distance = GetSymbolDistance(c, text); c.OrderIndex = distance; return(distance); }) .Distinct(new CompletionEqualityComparer()); var zeroIndex = new List <Completion>(); var properties = new List <Completion>(); var nodes = new List <Completion>(); var other = new List <Completion>(); foreach (var item in orderedByDistance) { if (item.OrderIndex == 0) { zeroIndex.Add(item); } else if (item.CompletionType == CompletionType.Property) { properties.Add(item); } else if (item.CompletionType == CompletionType.Node) { nodes.Add(item); } else { other.Add(item); } } WritableCompletions.Clear(); WritableCompletions.AddRange(zeroIndex.Concat(properties) .Concat(nodes) .Concat(other) .ToList()); if (WritableCompletions.Count > 0) { SelectionStatus = new CompletionSelectionStatus(WritableCompletions[0], true, true); } } catch (Exception e) { Debug.WriteLine("Filter failed"); Debug.WriteLine(e.ToString()); } }
public override void SelectBestMatch() { base.SelectBestMatch(); var snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; var userText = ApplicableTo.GetText(snapshot); // If VS couldn't find an exact match, try again without closing quote. if (SelectionStatus.IsSelected) { return; } //var originalSpan = ApplicableTo; //try //{ // var spanPoints = originalSpan.GetSpan(snapshot); // ApplicableTo = snapshot.CreateTrackingSpan(spanPoints.Start, spanPoints.Length - 1, ApplicableTo.TrackingMode); // base.SelectBestMatch(); //} //finally //{ ApplicableTo = originalSpan; } }
protected void CustomFilter(CompletionMatchType matchType, bool caseSensitive) { ITextSnapshot currentSnapshot = ApplicableTo.TextBuffer.CurrentSnapshot; var filterText = ApplicableTo.GetText(currentSnapshot).TrimEnd(); var predicate = GetFilterPredicate(filterText, matchType, caseSensitive); ((FilteredObservableCollection <Completion>)Completions).Filter(predicate); ((FilteredObservableCollection <Completion>)CompletionBuilders).Filter(predicate); }
/// <inheritdoc /> /// <remarks>This method first checks the <see cref="CompletionSet.SelectionStatus"/> property to /// determine if a <see cref="Completion"/> has been manually selected. This condition is identified by /// <em>all</em> of the following conditions being true. /// /// <list type="bullet"> /// <item><see cref="CompletionSelectionStatus.Completion"/> is not <see langword="null"/>.</item> /// <item><see cref="CompletionSelectionStatus.IsSelected"/> is <see langword="true"/>.</item> /// <item><see cref="CompletionSelectionStatus.IsUnique"/> is <see langword="true"/>.</item> /// <item><see cref="CompletionSet.SelectionStatus"/> is not equal to the /// <see cref="CompletionSet.SelectionStatus"/> value for either of the underlying completion sets; i.e. /// it was explicitly set for the augmented completion set.</item> /// </list> /// /// <para>Next, this method ensures that the last typed character is actually a letter. This test /// prevents <see cref="SelectBestMatch"/> from changing the current selection when the user types a /// non-letter character to commit the selection, such as <c><</c>, <c>/</c>, or <c>"</c>. When a /// non-letter character is typed, the augmented set assumes that the correct selection was made during /// a previous call to <see cref="SelectBestMatch"/>.</para> /// /// <para>This method calls <see cref="SelectBestMatch"/> on each of the underlying completion sets. If /// these calls result in a <em>single</em> unique selection, that selection is assigned to the /// <see cref="CompletionSet.SelectionStatus"/> property. Otherwise, the base implementation is called /// to determine the best selection from the augmented completion set.</para> /// /// <note type="note">A future implementation might provide a special interface that allows selecting a /// best match across multiple source <see cref="CompletionSet"/> instances, but for now we must rely on /// the default algorithm operating on the merged collections.</note> /// </remarks> public override void SelectBestMatch() { // Don't overwrite manually selected results if (SelectionStatus != null && SelectionStatus.Completion != null && SelectionStatus.IsSelected && SelectionStatus.IsUnique) { if (SelectionStatus != _source.SelectionStatus && SelectionStatus != _secondSource.SelectionStatus) { return; } } // If the typed character wasn't a letter, ignore this request (fixes handling of /, >, and other // characters triggering a completion) string completionText = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); if (completionText.Length > 0 && !char.IsLetter(completionText[completionText.Length - 1])) { return; } _source.SelectBestMatch(); _secondSource.SelectBestMatch(); bool firstUnique = _source.SelectionStatus != null && _source.SelectionStatus.IsUnique && !_secondSource.SelectionStatus.IsSelected; bool secondUnique = _secondSource.SelectionStatus != null && _secondSource.SelectionStatus.IsUnique && !_source.SelectionStatus.IsSelected; if (firstUnique && !secondUnique && _source.SelectionStatus.IsSelected) { this.SelectionStatus = _source.SelectionStatus; } else if (secondUnique && !firstUnique && _secondSource.SelectionStatus.IsSelected) { this.SelectionStatus = _secondSource.SelectionStatus; } else { base.SelectBestMatch(); } if (!_calculatedBestMatch && _session != null && RoslynHacks.RoslynUtilities.IsFinalRoslyn) { // Roslyn doesn't automatically commit a selected unique item when Ctrl+Space is pressed. This block // triggers the completion manually in this case, but only if the selection is unique at the time // Ctrl+Space is pressed (when _calculatedBestMatch is false). if (SelectionStatus.IsSelected && SelectionStatus.IsUnique) { _session.Commit(); } } _calculatedBestMatch = true; }
/// <summary> /// Determines the best match in the completion set. /// </summary> public override void SelectBestMatch() { if (_completions == null) { return; } var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); Completion bestMatch = _previousSelection; int bestValue = 0; bool isUnique = true; bool allowSelect = true; // Using the Completions property to only search through visible // completions. foreach (var comp in Completions) { int value = _comparer.GetSortKey(_matchInsertionText ? comp.InsertionText : comp.DisplayText, text); if (bestMatch == null || value > bestValue) { bestMatch = comp; bestValue = value; isUnique = true; } else if (value == bestValue) { isUnique = false; } } if (!CommitByDefault) { allowSelect = false; isUnique = false; } if (((DynamicallyVisibleCompletion)bestMatch).Visible) { SelectionStatus = new CompletionSelectionStatus( bestMatch, isSelected: allowSelect && bestValue > 0, isUnique: isUnique ); } else { SelectionStatus = new CompletionSelectionStatus( null, isSelected: false, isUnique: false ); } _previousSelection = bestMatch; }
private void FixTrackingSpan() { var currentSnapshot = ApplicableTo.TextBuffer.CurrentSnapshot; var text = ApplicableTo.GetText(currentSnapshot); if (text.EndsWith("}")) { ApplicableTo = currentSnapshot.CreateTrackingSpan(ApplicableTo.GetStartPoint(currentSnapshot).Position, text.Length - 1, SpanTrackingMode.EdgeInclusive); } }
public override void SelectBestMatch() { var filterText = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot).TrimEnd(); var directMatchItems = Completions.Where(c => DoesCompletionMatchApplicabilityTextDirect(c, filterText, CompletionMatchType.MatchInsertionText, false)).ToArray(); if (directMatchItems.Any()) { this.SelectionStatus = new CompletionSelectionStatus(directMatchItems[0], true, directMatchItems.Length == 1); } else { this.SelectionStatus = new CompletionSelectionStatus(null, false, false); } }
/// <summary> /// Filters the set of completions to those that match the applicability text of the completion set and determines the best match. /// </summary> public override void Filter() { var currentSnapshot = ApplicableTo.TextBuffer.CurrentSnapshot; filterBufferText = ApplicableTo.GetText(currentSnapshot).Trim(); if (string.IsNullOrEmpty(filterBufferText)) { filteredCompletions.StopFiltering(); filteredCompletionBuilders.StopFiltering(); } else { filteredCompletions.Filter(DoesCompletionMatchApplicabilityText); filteredCompletionBuilders.Filter(DoesCompletionMatchApplicabilityText); } }
protected void CustomFilter(CompletionMatchType matchType, bool caseSensitive) { ITextSnapshot currentSnapshot = ApplicableTo.TextBuffer.CurrentSnapshot; var filterText = ApplicableTo.GetText(currentSnapshot).TrimEnd(); if (string.IsNullOrEmpty(filterText)) { ((FilteredObservableCollection <Completion>)Completions).StopFiltering(); ((FilteredObservableCollection <Completion>)CompletionBuilders).StopFiltering(); } else { ((FilteredObservableCollection <Completion>)Completions).Filter(completion => DoesCompletionMatchApplicabilityText(completion, filterText, matchType, caseSensitive)); ((FilteredObservableCollection <Completion>)CompletionBuilders).Filter(completion => DoesCompletionMatchApplicabilityText(completion, filterText, matchType, caseSensitive)); } }
/// <summary> /// Determines and selects the only match in the completion set. /// This ignores the user's filtering preferences. /// </summary> /// <returns> /// True if a match is found and selected; otherwise, false if there /// is no single match in the completion set. /// </returns> public bool SelectSingleBest() { if (_completions == null) { return(false); } var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); Completion bestMatch = null; // Unfilter and then search all completions FilterToPredicate(_ => true); foreach (var comp in _completions) { if (_comparer.IsCandidateMatch(_matchInsertionText ? comp.InsertionText : comp.DisplayText, text)) { if (bestMatch == null) { bestMatch = comp; } else { return(false); } } } try { if (bestMatch != null) { SelectionStatus = new CompletionSelectionStatus( bestMatch, isSelected: true, isUnique: true ); return(true); } } catch (Exception ex) when(!ex.IsCriticalException()) { ex.ReportUnhandledException(null, GetType(), allowUI: false); } return(false); }
public override void Filter() { ITextSnapshot snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; string typedText = ApplicableTo.GetText(snapshot).Trim(); List <Completion> temp = new List <Completion>(); foreach (Completion comp in _allCompletions) { int index = comp.DisplayText.IndexOf(typedText, StringComparison.OrdinalIgnoreCase); if (index > -1) { temp.Add(comp); } } _filteredCompletions = temp; }
public override void SelectBestMatch() { _typed = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); CustomFilter(); IOrderedEnumerable <Completion> ordered = currentCompletions.OrderByDescending(c => GetHighlightedSpansInDisplayText(c.DisplayText).Sum(s => s.Length)); if (ordered.Any()) { int count = ordered.Count(); SelectionStatus = new CompletionSelectionStatus(ordered.First(), count == 1, count == 1); } else { SelectBestMatch(CompletionMatchType.MatchDisplayText, false); } }
/// <inheritdoc /> /// <remarks>This method first checks the <see cref="CompletionSet.SelectionStatus"/> property to /// determine if a <see cref="Completion"/> has been manually selected. This condition is identified by /// <em>all</em> of the following conditions being true. /// /// <list type="bullet"> /// <item><see cref="CompletionSelectionStatus.Completion"/> is not <see langword="null"/>.</item> /// <item><see cref="CompletionSelectionStatus.IsSelected"/> is <see langword="true"/>.</item> /// <item><see cref="CompletionSelectionStatus.IsUnique"/> is <see langword="true"/>.</item> /// <item><see cref="CompletionSet.SelectionStatus"/> is not equal to the /// <see cref="CompletionSet.SelectionStatus"/> value for either of the underlying completion sets; i.e. /// it was explicitly set for the augmented completion set.</item> /// </list> /// /// <para>Next, this method ensures that the last typed character is actually a letter. This test /// prevents <see cref="SelectBestMatch"/> from changing the current selection when the user types a /// non-letter character to commit the selection, such as <c><</c>, <c>/</c>, or <c>"</c>. When a /// non-letter character is typed, the augmented set assumes that the correct selection was made during /// a previous call to <see cref="SelectBestMatch"/>.</para> /// /// <para>This method calls <see cref="SelectBestMatch"/> on each of the underlying completion sets. If /// these calls result in a <em>single</em> unique selection, that selection is assigned to the /// <see cref="CompletionSet.SelectionStatus"/> property. Otherwise, the base implementation is called /// to determine the best selection from the augmented completion set.</para> /// /// <note type="note">A future implementation might provide a special interface that allows selecting a /// best match across multiple source <see cref="CompletionSet"/> instances, but for now we must rely on /// the default algorithm operating on the merged collections.</note> /// </remarks> public override void SelectBestMatch() { // Don't overwrite manually selected results if (SelectionStatus != null && SelectionStatus.Completion != null && SelectionStatus.IsSelected && SelectionStatus.IsUnique) { if (SelectionStatus != _source.SelectionStatus && SelectionStatus != _secondSource.SelectionStatus) { return; } } // If the typed character wasn't a letter, ignore this request (fixes handling of /, >, and other // characters triggering a completion) string completionText = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); if (completionText.Length > 0 && !char.IsLetter(completionText[completionText.Length - 1])) { return; } _source.SelectBestMatch(); _secondSource.SelectBestMatch(); bool firstUnique = _source.SelectionStatus != null && _source.SelectionStatus.IsUnique && !_secondSource.SelectionStatus.IsSelected; bool secondUnique = _secondSource.SelectionStatus != null && _secondSource.SelectionStatus.IsUnique && !_source.SelectionStatus.IsSelected; if (firstUnique && !secondUnique && _source.SelectionStatus.IsSelected) { this.SelectionStatus = _source.SelectionStatus; } else if (secondUnique && !firstUnique && _secondSource.SelectionStatus.IsSelected) { this.SelectionStatus = _secondSource.SelectionStatus; } else { base.SelectBestMatch(); } }
public override void SelectBestMatch() { ITextSnapshot snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; string typedText = ApplicableTo.GetText(snapshot); if (string.IsNullOrWhiteSpace(typedText)) { if (this.WritableCompletions.Any()) { SelectionStatus = new CompletionSelectionStatus(WritableCompletions.First(), true, true); } return; } foreach (CrmCompletion comp in WritableCompletions) { if (comp.IsMatch(typedText)) { SelectionStatus = new CompletionSelectionStatus(comp, true, true); return; } } }
public override void SelectBestMatch() { ITextSnapshot snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; string typedText = ApplicableTo.GetText(snapshot); if (string.IsNullOrWhiteSpace(typedText)) { if (this.WritableCompletions.Any()) { SelectionStatus = new CompletionSelectionStatus(WritableCompletions.First(), true, true); } return; } foreach (Completion comp in WritableCompletions) { if (comp.DisplayText.IndexOf(typedText, StringComparison.InvariantCultureIgnoreCase) > -1) { SelectionStatus = new CompletionSelectionStatus(comp, true, true); return; } } }
/// <summary> /// Restricts the set of completions to those that match the applicability text /// of the completion set, and then determines the best match. /// </summary> public override async void Filter() { if (_filteredCompletions == null) { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = true; } return; } var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); if (text.Length > 0) { bool anyVisible = false; foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { if (_shouldHideAdvanced && IsAdvanced(c) && !text.StartsWith("__")) { c.Visible = false; } else if (_shouldFilter) { c.Visible = _comparer.IsCandidateMatch(c.DisplayText, text); } else { c.Visible = true; } anyVisible |= c.Visible; } if (!anyVisible) { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { // UndoVisible only works reliably because we always // set Visible in the previous loop. c.UndoVisible(); } } _filteredCompletions.Filter(IsVisible); if (_options.DeferredLoadPreCharacters > 0) { var useText = text; if (text.Length > _options.DeferredLoadPreCharacters) { useText = text.Substring(0, _options.DeferredLoadPreCharacters); if (_loadedDeferredCompletionSubsets.Contains(useText)) { return; } } else if (text.Length < _options.DeferredLoadPreCharacters) { return; } // check to see if the deferred load has been done already if (_deferredLoadCallback != null && !_loadedDeferredCompletionSubsets.Contains(useText)) { _loadedDeferredCompletionSubsets.Add(text); var completions = await Task.Factory.StartNew <IList <DynamicallyVisibleCompletion> >(() => _deferredLoadCallback(text).ToList()); _filteredCompletions.AddRange(completions); SelectBestMatch(); } } } else if (_shouldHideAdvanced) { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } else { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = true; } _filteredCompletions.StopFiltering(); } }
/// <summary> /// Determines the best match in the completion set. /// </summary> public override void SelectBestMatch() { var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); Completion bestMatch = _previousSelection; int bestValue = 0; bool isUnique = true; bool allowSelect = true; if (!string.IsNullOrWhiteSpace(text)) { // Using the Completions property to only search through visible // completions. foreach (var comp in Completions) { int value = _comparer.GetSortKey(comp.DisplayText, text); if (bestMatch == null || value > bestValue) { bestMatch = comp; bestValue = value; isUnique = true; } else if (value == bestValue) { isUnique = false; } } } else { foreach (var comp in Completions) { int temp; if (IntellisenseExtensions.LastCommittedCompletions.TryGetValue(comp.DisplayText, out temp)) { if (bestMatch == null || temp > bestValue) { bestMatch = comp; bestValue = temp; isUnique = true; } } } } if (bestMatch == null) { bestMatch = Completions[0]; } if (((DynamicallyVisibleCompletion)bestMatch).Visible) { SelectionStatus = new CompletionSelectionStatus(bestMatch, isSelected: allowSelect && bestValue > 0, isUnique: isUnique); } else { SelectionStatus = new CompletionSelectionStatus(null, isSelected: false, isUnique: false); } _previousSelection = bestMatch; }
/// <summary> /// Restricts the set of completions to those that match the applicability text /// of the completion set, and then determines the best match. /// </summary> public override void Filter() { if (_completions == null) { return; } if (_filteredCompletions == null) { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = true; } return; } var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot); if (text.Length > 0) { bool hideAdvanced = _shouldHideAdvanced && !text.StartsWith("__"); bool anyVisible = false; foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { if (hideAdvanced && IsAdvanced(c)) { c.Visible = false; } else if (_shouldFilter) { c.Visible = _comparer.IsCandidateMatch(_matchInsertionText ? c.InsertionText : c.DisplayText, text); } else { c.Visible = true; } anyVisible |= c.Visible; } if (!anyVisible) { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { // UndoVisible only works reliably because we always // set Visible in the previous loop. c.UndoVisible(); } } _filteredCompletions.Filter(IsVisible); } else if (_shouldHideAdvanced) { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = !IsAdvanced(c); } _filteredCompletions.Filter(IsVisible); } else { foreach (var c in _completions.Cast <DynamicallyVisibleCompletion>()) { c.Visible = true; } _filteredCompletions.StopFiltering(); } }
private string GetTypedText() { ITextSnapshot snapshot = ApplicableTo.TextBuffer.CurrentSnapshot; return(ApplicableTo.GetText(snapshot)); }