-
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
Keep track of trigger location for individual CompletionItem #55035
Conversation
02f9a5c
to
cc6b41e
Compare
Fix committing completion item and expander in projection scenarios
cc6b41e
to
fff91e2
Compare
var snapshotForDocument = data.InitialSortedList.FirstOrDefault(item => item.Properties.ContainsProperty(CompletionSource.TriggerLocation)) is VSCompletionItem firstItem && | ||
firstItem.Properties.GetProperty(CompletionSource.TriggerLocation) is SnapshotPoint triggerLocation | ||
? triggerLocation.Snapshot | ||
: data.Snapshot; |
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.
Data is captured here in the lambda, most of the other lambdas are static in the method 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.
this is just really hard to read. can you make this a simple helper function.
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.
which should always be available
If it shoudl always be available, we should either assert/contract so we get a stack when something breaks expectations. being defensive just means unexplainable bugs happen and we have no idea what is going on.
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.
Data is captured here in the lambda, most of the other lambdas are static in the method here.
I don't see anything got captured, but I did extract a local function here
If it shoudl always be available, we should either assert/contract so we get a stack when something breaks expectations. being defensive just means unexplainable bugs happen and we have no idea what is going on.
Add some comments to clarify
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CompletionSource.cs
Outdated
Show resolved
Hide resolved
// since the intial trigger we are able to get from IAsyncCompletionSession might not be the same (e.g. in projection scenarios,) | ||
// so when they are requested via expander later, we can retrieve it,. | ||
// Techinically we should save the trigger location for each individual service that made such claim, but in reality , only Roslyn's completion service uses | ||
// expander, so we can get away with not making such distinction. |
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.
i really don't get teh explanation.
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.
i think this might actually be an issue with how Editor handle expander in old razor editor.
In the example below, when completion is triggered, our implementation of GetCompletionContextAsync
is called twice, once with trigger location in C# buffer, another with trigger location in TS buffer. However, when user then hit expander, GetExpandedCompletionContextAsync
is only called once with triggerLocation pointing to the HTML buffer, as a result we don't know which underlying document we should ask for expanded item for (i.e. cs vs ts).
But as mentioned in the comment, only Roslyn's provider actually use Expander, so in reality this will not cause any problem.
@jinujoseph @vatsalyaagrawal I think we should take this for 16.11. Please confirm then I will create a shiproom bug for it. Thanks |
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.
LGTM, although I'm not very familiar with the code so just basing my approval off what I can deduce from the PR 😃
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/CompletionSource.cs
Outdated
Show resolved
Hide resolved
src/EditorFeatures/Core/Implementation/IntelliSense/AsyncCompletion/ItemManager.cs
Outdated
Show resolved
Hide resolved
…etion/CompletionSource.cs Co-authored-by: Allison Chou <[email protected]>
…etion/ItemManager.cs Co-authored-by: Allison Chou <[email protected]>
Thanks @allisonchou! |
Fix committing completion item and expander in projection scenarios. Address #51702