Skip to content
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

Consolidate data tracked over an async completion session #59553

Merged
merged 9 commits into from
Feb 17, 2022

Conversation

genlu
Copy link
Member

@genlu genlu commented Feb 15, 2022

Fix #59262

Based on the public async completion API, it's not mentioned that the same session object would be used over an async completion session, even though the underlying implementation guarantees it. So I have aggregated all data into a single object but still uses the property bag to track it over the session, instead of using a CWT.

private CompletionItemData(RoslynCompletionItem roslynItem, SnapshotPoint? triggerLocation)
{
RoslynItem = roslynItem;
TriggerLocation = triggerLocation ?? new();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❕ Don't use new T() (or new()) for value types unless they have a default constructor. Also, I'm concerned this line may be treating new() as new SnapshotPoint() and not new Optional<SnapshotPoint>() (even if it's not, it's confusing).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, new() here actually is new SnapshotPoint(). Fixed

public bool HasSuggestionItemOptions { get; set; }

public Optional<SnapshotPoint> ExpandedItemTriggerLocation { get; set; }
public Optional<TextSpan> CompletionListSpan { get; set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can all of these be optional at different times? Or does one being provided mean the rest are provided as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the following three could be in one such group, but I'm not sure I'd like to have another type to bundle them together (if that's what you are suggesting)

        public Optional<SnapshotPoint> ExpandedItemTriggerLocation { get; set; }
        public Optional<TextSpan> CompletionListSpan { get; set; }
        public Optional<ImmutableArray<char>> ExcludedCommitCharacters { get; set; }

internal const string ExpandedItemsTask = nameof(ExpandedItemsTask);

// Don't change this property! Editor code currently has a dependency on it.
internal const string ExcludedCommitCharacters = nameof(ExcludedCommitCharacters);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@genlu genlu Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olegtk @AmadeusW This feels so wrong. Any idea how can we remove this dependency?
tracking bug: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1484552

@genlu genlu enabled auto-merge February 17, 2022 00:57
@genlu genlu merged commit ed5caf4 into dotnet:main Feb 17, 2022
@ghost ghost added this to the Next milestone Feb 17, 2022
@genlu genlu deleted the SessionData branch February 18, 2022 06:52
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P2 Mar 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consolidate data tracked over an async completion session
4 participants