Skip to content

Patch VS Code to wait for storage write #2049

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

Merged
merged 1 commit into from
Sep 3, 2020
Merged

Conversation

code-asher
Copy link
Member

Confirmed that it fixes rust-lang/rust-analyzer#5892 (reported in #2021).

@code-asher code-asher requested a review from nhooyr as a code owner September 2, 2020 22:22
Copy link
Contributor

@nhooyr nhooyr left a comment

Choose a reason for hiding this comment

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

What's causing so many lines in the patch to change?

* operation to either the current workspace only or all workspaces.
*/
- store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): void;
+ store(key: string, value: string | boolean | number | undefined | null, scope: StorageScope): Promise<void> | void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why | void?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are a bunch of tests that implement this interface. We could modify them all to return promises instead of void but it would increase the patch size a decent amount.

@code-asher
Copy link
Member Author

code-asher commented Sep 3, 2020

It looks like my version of git outputs index hashes that are 10 characters in length while the version used by the last person to generate the patch outputs 11 characters. As far as I can tell this isn't configurable yet (it will be in the next version).

But I'm thinking we should modify the patch script to use --full-index, then no matter what version of git you use the hashes will be the same length.

VS Code has a short delay before writing storage (probably to queue up
rapid changes). In the web version of VS Code this happens on the client
which means if the page is reloaded before the delay expires the write
never happens.

Storage updates are already promises so this simply returns the promise
returned by the delayer so it won't resolve until the write actually
happens.

Fixes #2021.
@code-asher
Copy link
Member Author

I removed the extraneous hash updates. 😄

@nhooyr
Copy link
Contributor

nhooyr commented Sep 3, 2020

But I'm thinking we should modify the patch script to use --full-index, then no matter what version of git you use the hashes will be the same length.

Sounds good, go ahead and do that!

@nhooyr
Copy link
Contributor

nhooyr commented Sep 3, 2020

In a separate commit of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants