-
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
Conversation
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.
No specific change request, but I'd like to go over the specific rules with you to make sure I'm on the same page here.
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.
Same as Sam, I want to understand 5 and 6 more as they don't make sense to me currently.
@dpoeschl , @sharwell , please unblock the PR:
|
@ivanbasov Okay. I thought you meant that the user would press down and it'd jump to somewhere else in the list that was "next to" the starred item alphabetically. But I think what you mean is that if the user types an additional character that changes from having a starred match to a non-starred match, then it's okay to jump. Correct? |
Thank you for the confirmation, @dpoeschl ! Correct: I mean that adding or deleting characters may jump between starred and non-starred items. If you do not mind, please review the PR. Thank you! |
Definitely interested in this convo. While i thnk intellicode is great, i'm a little concerned about it overriding things like the MRU when incorrect. |
I'm a little confused by this. that's how MRU should be working anyways. MRU certainly shouldn't see the 'star' or not. I believe i submitted a PR to ensure that things like the star were not part of the 'text' and were simply a 'prefix adornment' precisely so we wouldn't have any sorts of leaks between these two systems. Please advise on this. |
See: /// <summary>
/// The text that is displayed to the user.
/// </summary>
public string DisplayText { get; }
/// <summary>
/// An optional prefix to be displayed prepended to <see cref="DisplayText"/>. Can be null.
/// Pattern-matching of user input will not be performed against this, but only against <see
/// cref="DisplayText"/>.
/// </summary>
public string DisplayTextPrefix { get; } Note that the MRU works like this: internal static int GetRecentItemIndex(ImmutableArray<string> recentItems, RoslynCompletionItem item)
{
var index = recentItems.IndexOf(item.DisplayText);
return -index;
} So i cannot explain any sort of behavior you're seeing that would need fixing... |
Thank you, @CyrusNajmabadi ! The star is a part of the DisplayText now. @dpoeschl may know more why. |
Honestly, can we just fix this by loooking for that and rewriting the completion item to be in the appropriate form? If we're going to add all this code to 'unhork' things, that seems like the most sensible way to do things. |
|
Works for me. Thanks! |
Note: the PR to fix these issues with display-texts and prefixes was added about 10 months ago here: #26764. The internal work to get it properly used doesn't seem to have been done. |
I'm a little foggy, but I think the reason IntelliCode offers items the way it does is because it is backward compatible to VS 15.something. If/when we bump our Roslyn reference version we can get rid of some reflection and improve things like this. |
interesting. but none of our changes here will help VS15 right? Since these changes will only go into VS2019 and above? If htat's the case, can we have intellicode just check whcih version they're on and use the right entrypoints accordingly? At the same time, we could put in a simple hack on our side to check if the display string starts with the star, and munge things properly so that we odn't have to then fix the fallout in later points in the code. Thanks! |
|
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/Helpers.cs
Outdated
Show resolved
Hide resolved
|
||
// This is a temporarily method to support preferrrence of IntelliCode items comparing to non-IntelliCode items. | ||
// We expect that Editor will intorduce this support and we will get rid of relying on the "★" then. | ||
internal static bool IsPreferredItem(this RoslynCompletionItem completionItem) |
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.
@@ -493,7 +493,8 @@ private static bool ShouldBeFilteredOutOfCompletionList(VSCompletionItem item, I | |||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
💡 !bestItem.IsPreferredItem()
is an unnecessary check here
(mruIndex2 == mruIndex1 && !bestItem.IsPreferredItem() && chosenItem.IsPreferredItem())) | |
(mruIndex2 == mruIndex1 && chosenItem.IsPreferredItem())) |
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.
Well, it depends. For example, there are starred Last
and Length
, and match by L
. Which one we should prefer? The current idea is to prefer the first item. Also the pattern we follow in this method is to use the chosen item only if it exceeds the current best one. So, let us follow the pattern consistently.
I'm not sure i undertand this. Why can't we move the stars? I'm not asking for intellicode to move tehm (though they should). I'm saying: we can detect things on our end and fix things up so that our internal model is being used correctly. |
Here is a summary of the design meeting with the IntelliCode team: