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

fix: Fix process-changes not deduplicating changes correctly #14025

Merged
merged 1 commit into from Jan 25, 2023

Conversation

Veykril
Copy link
Member

@Veykril Veykril commented Jan 25, 2023

probably fixes #12873 (will close it with this nevertheless as its not really reproducible)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 25, 2023
@jonas-schievink
Copy link
Contributor

This seems more correct than before, yeah.

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 25, 2023

📌 Commit d712e52 has been approved by jonas-schievink

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jan 25, 2023

⌛ Testing commit d712e52 with merge dd673ee...

@bors
Copy link
Collaborator

bors commented Jan 25, 2023

☀️ Test successful - checks-actions
Approved by: jonas-schievink
Pushing dd673ee to master...

@bors bors merged commit dd673ee into rust-lang:master Jan 25, 2023
true
}
// can't really occur
(Modify, Create) => false,
(Delete, Modify) => false,
}
});

if collapsed_create_delete {
changed_files.pop();
Copy link
Member

@lnicola lnicola Jan 26, 2023

Choose a reason for hiding this comment

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

I've only skimmed the changes, but does this work for [Create(f1), Delete(f1), Create(f2), Delete(f2)]?

And generally, I don't think dedup_by guarantees anything about the order of calls. Maybe we should "just" keep a map from FileId to ChangeKind, and go over the input once and update the map, without sorting it first? It might even be (asymptotically) faster. We only keep one ChangeKind per file, except for the "can't really occur" cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

It should work, because the flag is only true at this point if it was set to true during the last call to the closure (the beginning of the closure resets it to false).

I agree that the code is hard to follow though, and dedup_by is probably not helping with that.

Copy link
Member

@lnicola lnicola Jan 26, 2023

Choose a reason for hiding this comment

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

But on my example, this results in [Delete(f1)] instead of [], which is probably not desirable. collapsed_create_delete will only cause the last Delete to be dropped.

Copy link
Member Author

Choose a reason for hiding this comment

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

A simple map might be a better choice here indeed

@Veykril Veykril deleted the changekind-fix branch January 27, 2023 13:17
bors added a commit that referenced this pull request Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

thread 'LspServer' panicked at 'called Option::unwrap() on a None value', crates/vfs/src/lib.rs:133:38
5 participants