-
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
Avoid linking back to the original TreeSource in document state updates if the associated lazy is already completed #75355
Avoid linking back to the original TreeSource in document state updates if the associated lazy is already completed #75355
Conversation
…es if the associated lazy is already completed Previously, I was seeing pull diagnostics requests for linked documents as computing the changes between the original and current version of the file. Instead, change the code where we determine the tree source to use the latest tree source if it's been calculated.
@@ -69,8 +69,11 @@ public DocumentState UpdateTextAndTreeContents( | |||
// We only need to look one deep here as we'll pull that tree source forward to our level. If another link is | |||
// later added to us, it will do the same thing. | |||
var originalTreeSource = this.TreeSource; | |||
if (originalTreeSource is LinkedFileReuseTreeAndVersionSource linkedFileTreeAndVersionSource) | |||
if (originalTreeSource is LinkedFileReuseTreeAndVersionSource linkedFileTreeAndVersionSource | |||
&& !linkedFileTreeAndVersionSource.TryGetValue(out var _)) |
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 def needs docs.
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.
alternatively, if you are able to get the value from the linkedSource, why not pass it along instead? And if you can't, you defer to the original tree source it points to.
Also, i think we should doc .OriginalTreeSource. Mention that it's there to produce a long chain if we haven't computed the intermediary steps. But if we have, we'll use that value instead.
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.
Moved code around a bit and added some comments.
Removed my approval. I would like to see if this can be potentially different. |
@@ -24,7 +24,26 @@ private sealed class LinkedFileReuseTreeAndVersionSource( | |||
ITreeAndVersionSource originalTreeSource, | |||
AsyncLazy<TreeAndVersion> lazyComputation) : ITreeAndVersionSource | |||
{ | |||
public readonly ITreeAndVersionSource OriginalTreeSource = originalTreeSource; | |||
// Used as a fallback value in GetComputedTreeAndVersionSource to avoid long lazy chain evaluations. | |||
private readonly ITreeAndVersionSource _originalTreeSource = originalTreeSource; |
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.
doc comments :)
/// </remarks> | ||
public ITreeAndVersionSource GetNonChainedTreeAndVersionSource() | ||
{ | ||
if (TryGetValue(out _)) |
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.
conditional expr.
Previously, I was seeing pull diagnostics requests for linked documents as computing the changes between the original and current version of the file. Instead, change the code where we determine the tree source to use the latest tree source if it's been calculated.