-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Completion should select IntelliCode item when possible #37066
Changes from all commits
e893550
79a476b
3182e8e
7559617
4e6fdc0
7cfd54c
58a3049
5097c6e
1a0eccc
149a8fc
61dd643
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -293,12 +293,12 @@ private FilteredCompletionModel HandleNormalFiltering( | |||||
if (bestItem != null) | ||||||
{ | ||||||
selectedItemIndex = itemsInList.IndexOf(i => Equals(i.FilterResult.CompletionItem, bestItem)); | ||||||
var deduplicatedList = matchingItems.Where(r => !r.DisplayText.StartsWith("★")); | ||||||
var deduplicatedListCount = matchingItems.Where(r => !r.IsPreferredItem()).Count(); | ||||||
if (selectedItemIndex > -1 && | ||||||
deduplicatedList.Count() == 1 && | ||||||
deduplicatedListCount == 1 && | ||||||
filterText.Length > 0) | ||||||
{ | ||||||
var uniqueItemIndex = itemsInList.IndexOf(i => Equals(i.FilterResult.CompletionItem, deduplicatedList.First())); | ||||||
var uniqueItemIndex = itemsInList.IndexOf(i => Equals(i.FilterResult.CompletionItem, bestItem)); | ||||||
uniqueItem = highlightedList[uniqueItemIndex].CompletionItem; | ||||||
} | ||||||
} | ||||||
|
@@ -391,7 +391,7 @@ private FilteredCompletionModel HandleDeletionTrigger( | |||||
hardSelect = false; | ||||||
} | ||||||
|
||||||
var deduplicatedListCount = matchingItems.Where(r => !r.VSCompletionItem.DisplayText.StartsWith("★")).Count(); | ||||||
var deduplicatedListCount = matchingItems.Where(r => !r.VSCompletionItem.IsPreferredItem()).Count(); | ||||||
|
||||||
return new FilteredCompletionModel( | ||||||
highlightedList, index, filters, | ||||||
|
@@ -493,7 +493,8 @@ internal static RoslynCompletionItem GetBestCompletionItemBasedOnMRU( | |||||
var mruIndex1 = GetRecentItemIndex(recentItems, bestItem); | ||||||
var mruIndex2 = GetRecentItemIndex(recentItems, chosenItem); | ||||||
|
||||||
if (mruIndex2 < mruIndex1) | ||||||
if ((mruIndex2 < mruIndex1) || | ||||||
(mruIndex2 == mruIndex1 && !bestItem.IsPreferredItem() && chosenItem.IsPreferredItem())) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it depends. For example, there are starred |
||||||
{ | ||||||
bestItem = chosenItem; | ||||||
} | ||||||
|
@@ -513,7 +514,8 @@ internal static RoslynCompletionItem GetBestCompletionItemBasedOnMRU( | |||||
var bestItemPriority = bestItem.Rules.MatchPriority; | ||||||
var currentItemPriority = chosenItem.Rules.MatchPriority; | ||||||
|
||||||
if (currentItemPriority > bestItemPriority) | ||||||
if ((currentItemPriority > bestItemPriority) || | ||||||
((currentItemPriority == bestItemPriority) && !bestItem.IsPreferredItem() && chosenItem.IsPreferredItem())) | ||||||
{ | ||||||
bestItem = chosenItem; | ||||||
} | ||||||
|
@@ -524,7 +526,7 @@ internal static RoslynCompletionItem GetBestCompletionItemBasedOnMRU( | |||||
|
||||||
internal static int GetRecentItemIndex(ImmutableArray<string> recentItems, RoslynCompletionItem item) | ||||||
{ | ||||||
var index = recentItems.IndexOf(item.DisplayText); | ||||||
var index = recentItems.IndexOf(item.FilterText); | ||||||
return -index; | ||||||
} | ||||||
|
||||||
|
@@ -565,7 +567,13 @@ internal static bool IsBetterDeletionMatch(FilterResult result1, FilterResult re | |||||
{ | ||||||
return true; | ||||||
} | ||||||
|
||||||
if (result1.CompletionItem.IsPreferredItem() && !result2.CompletionItem.IsPreferredItem()) | ||||||
{ | ||||||
return true; | ||||||
} | ||||||
} | ||||||
|
||||||
return false; | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ How is sorting performed? Can we not use the same strategy here (i.e. among two items with the same filter text, prefer to select the first one in sort order)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, no. Editor maintains multiple items lists: full, sorted, and filtered. They ask us for sorting before. However, they send us the full unsorted list for filtering.