-
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
Fix LSP completions when all items have default commit characters #55262
Conversation
@@ -49,8 +49,7 @@ static CompletionItemRules MakeRule((bool importDirective, bool preselect, bool | |||
{ | |||
// '<' should not filter the completion list, even though it's in generic items like IList<> | |||
var generalBaseline = CompletionItemRules.Default. | |||
WithFilterCharacterRule(CharacterSetModificationRule.Create(CharacterSetModificationKind.Remove, '<')). | |||
WithCommitCharacterRule(CharacterSetModificationRule.Create(CharacterSetModificationKind.Add, '<')); |
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.
<
is part of the default commit characters set and doesn't need to be specified here as best I can tell, cc @genlu
@@ -365,7 +366,9 @@ static void PromoteCommonCommitCharactersOntoList(LSP.VSCompletionList completio | |||
var commitCharacters = completionItem.CommitCharacters; | |||
if (commitCharacters == null) | |||
{ | |||
continue; | |||
// The commit characters on the item are null, this means the commit characters are actually |
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.
This fixes two issues
- We would hit a null ref on line 384 if all of the completion items had default commit characters (aka the commit characters field on every completion item was null).
- The algorithm is trying to promote the most used commit character set onto the list itself, then null out commit chars on any completion item using that set to save serialization. However this skipped originally null commit chars (indicating that the item should use commit chars from
Initialize
). This resulted in the second most used commit char set being promoted to theCompletionList.CommitChars
, and both items with default chars and second most used commit chars having their commit chars nulled out. This means for items that originally had null commit chars (aka use default fromInitialize
), the client would use the wrong commit chars from the completion list.
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.
resulted in the second most used commit char set being promoted
lol 🤦♂️
Good find!
Fixes an exception stack trace seen in https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1362284
Also fixes behavior of promotion of commit characters to the list to include default commit characters