Skip to content

Introduce a better system for keeping track if a buffer is visible or not in tagging#60500

Merged
CyrusNajmabadi merged 16 commits into
dotnet:main-vs-depsfrom
CyrusNajmabadi:betterVisibility
Apr 1, 2022
Merged

Introduce a better system for keeping track if a buffer is visible or not in tagging#60500
CyrusNajmabadi merged 16 commits into
dotnet:main-vs-depsfrom
CyrusNajmabadi:betterVisibility

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Mar 31, 2022

IDocumentTrackingService is not great (it doesn't work in repl i've found). This is a much clearer and cleaner association with the textview itself and if it's visible.

This is extracted from teh Pause-Taggers PR here #60371. That way Pause/Unpause is in an independent chunk we merge.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner March 31, 2022 01:56
@CyrusNajmabadi CyrusNajmabadi requested a review from a team March 31, 2022 01:56
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner March 31, 2022 01:56
@ghost ghost added the Area-IDE label Mar 31, 2022
// all open documents, which can lead to cancellation of diagnostic recomputation task
// for the newly active document. This can lead to a race condition where we end up with
// stale diagnostics for the active document. We avoid that by always recomputing
// the diagnostics for the newly active document whenever active document is switched.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is a merge of #60365


private void AssociatedViewService_SubjectBuffersConnected(object sender, SubjectBuffersConnectedEventArgs e)
{
Contract.ThrowIfFalse(_threadingContext.HasMainThread);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FTAO is affectively just a legacy wrapper around IThreadingContext. I'd prefer we just remove FTAO and use IThreadingContext in all places instead :)


// if any of the views were *not* wpf text views, assume the buffer is visible. We don't know how to
// determine the visibility of this buffer.
if (views.Any(v => v is not IWpfTextView))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what would be a valid case of us using this and having a non wpf view? Is expected that calling this for a C#/vb/ts/f# buffer would not be?

Just wondering if this a bug in the caller and should throw

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

that's a really good question. let me investigate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

so we can't prove that every one of our buffers is hosted in an IWpfTextView (even in VS). Plugins, for example, coudl create buffers with our content type and associate them with other buffers. i will doc this.

@CyrusNajmabadi CyrusNajmabadi requested a review from dibarbet March 31, 2022 17:43
// something see it is not visible, but then do not hear about its visibility change because we've hooked up
// our event after that happens.
var visibilityChangedTaskSource = new TaskCompletionSource<bool>();
var callback = new VisibilityCallback(visibilityChangedTaskSource);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

so this brings me to a question on the original API - any reason why the callback isn't a func or something similar? Seems like each consumer needs a bit more boilerplate to use the ITextBufferVisibilityChangedCallback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

talked offline. pros/cons to both approaches. for a later PR i thought this was nicer. but i don't feel strongly.


/// <summary>
/// Registers to hear about visibility changes for this particular buffer.
/// Registers to hear about visibility changes for this particular buffer. Not: registration will not trigger a
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit - Note:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed.

Comment thread src/EditorFeatures/Core/Workspaces/ITextBufferVisibilityTracker.cs Outdated
@allisonchou allisonchou changed the base branch from release/dev17.3 to main-vs-deps March 31, 2022 18:11
@allisonchou
Copy link
Copy Markdown
Contributor

allisonchou commented Mar 31, 2022

Re-targeting from release/dev17.3 to main-vs-deps so we can delete the release/dev17.3 branch.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner March 31, 2022 23:40
@CyrusNajmabadi CyrusNajmabadi merged commit ef9b5bd into dotnet:main-vs-deps Apr 1, 2022
@ghost ghost added this to the Next milestone Apr 1, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the betterVisibility branch April 1, 2022 15:20
@dibarbet dibarbet modified the milestones: Next, 17.3.P1 Apr 25, 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.

4 participants