-
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
Merge touch document actions #73399
Merge touch document actions #73399
Conversation
ProjectState oldProjectState, | ||
ProjectState newProjectState, | ||
DocumentState oldState, |
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.
passing in oldState/oldStates is redundant given that we have oldProjectState.
@ToddGrun ptal. |
{ | ||
private readonly DocumentState _oldState = oldState; | ||
private readonly DocumentState _newState = newState; | ||
private readonly ImmutableArray<DocumentState> _oldStates = newStates.SelectAsArray(s => oldProjectState.DocumentStates.GetRequiredState(s.Id)); |
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.
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.
it can be. but then i needed this here and for the sequence-equals. so basically, it was just nice to have the member.
note: if there's a problem here, we could always change this to be a OneOrMany. It's highly likely that thsi will be the 'One' case for the normal mode of a user editing a document. So we'd save on the array in that case. That said. I think this is unlikely to matter in practice since the arrays will be small, and GC'ed asap. So i'd like to keep this as-is for simplicity.
if (priorAction is TouchDocumentAction priorTouchAction && | ||
priorTouchAction._newState == _oldState) | ||
if (priorAction is TouchDocumentsAction priorTouchAction && | ||
priorTouchAction._newStates.SequenceEqual(_oldStates)) |
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.
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.
it's very likely. this is what happens when you get a stream of edits coming in for one document (basically, the typing scenario).
we can either keep making a longer and longer chain of 'edits' where the compilation goes through N steps to get to hte end. Or we can say that the actions 'merge' and we'll jump from teh starting compilation all the way to teh end step.
So, instead of A->B->C->D, we can collapse as we're adding these and end up with just an A->D transition.
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.
@jasonmalinowski For review when you get back. |
I figured out what this logic was trying to do and i was able to merge the types.