-
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
Ensure discards are initially soft selected in VSCode #75655
Conversation
@@ -363,6 +363,82 @@ internal static void FilterItems( | |||
} | |||
} | |||
|
|||
internal static bool IsHardSelection(CompletionItem item, bool matchedFilterText, bool hasSuggestionModeItem, string filterText) |
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.
everything in this file is moved unchanged
src/LanguageServer/Protocol/Handler/Completion/CompletionHandler.cs
Outdated
Show resolved
Hide resolved
if (matchResultsBuilder.Count > 0) | ||
{ | ||
var bestResult = GetBestCompletionItemSelectionFromFilteredResults(matchResultsBuilder); | ||
isHardSelection = CompletionService.IsHardSelection(bestResult.CompletionItem, bestResult.ShouldBeConsideredMatchingFilterText, completionList.SuggestionModeItem != null, filterText); |
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 this part needed to handle soft-selecting _
? I think we could just use the result of IsAllPunctuation(filterText)
to decide both selection mode and isIncomplete
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.
Ah interesting, I can make that change
Resolves dotnet/vscode-csharp#7623
Unfortunately LSP doesn't give servers much control over filtering. Servers do not generally get callbacks as filter text is typed - meaning we generally are not able to modify hard vs soft selection after the initial list is presented.
However, we can force VSCode to call us back in some scenarios using the
isIncomplete
flag on the completion list. For this case, when we see only punctuation typed (_
), we set theisIncomplete
flag and unset the commit characters to mimic soft selection.As the user continues typing (e.g.
_o
) we get called again and we can update to hard selection if they are completing a variable.However - this does not cover every case of switching between hard/soft selection. It could be covered by always setting
isIncomplete
but that would be expensive as we're re-computing and reserializing the entire list.