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

WIP: Let rust-analyzer complete checks before gathering diagnostics #585

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PretzelVector
Copy link

Description

Need some feedback on this approach since I'm quite new to VSCode extension development and interoperability.

Problem: When Rust Analyzer runs its checks on save, it can take quite long on slower hardware. Agent often does not have diagnostics when proceeding.

This PR: If Rust Analyzer extension is running, we give it 1 second grace period to start up (show as busy) and wait maximum 30 seconds for it to complete before collecting diagnostics. Separate spin-up loop allows step to complete quickly on faster hardware. Currently usable.

Minimum Changes: Want to put this behind a configuration flag first and make timing values configurable.

Questions:

  • Would the project be okay to accept this kind of tool-specific change?
  • Are there other tools/extensions running on save that make it worth making this feature more generic?
  • Is this the correct place to add the hook?
  • Is there a better way to wait for changes? I could not identify a subscription mechanism.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Ad-hoc usage on rust and non-rust projects

Checklist:

  • My code follows the patterns of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Copy link

changeset-bot bot commented Jan 27, 2025

⚠️ No Changeset found

Latest commit: 9951dd7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@mrubens
Copy link
Collaborator

mrubens commented Jan 28, 2025

It's a good question - I honestly don't know the best way to handle. For what it's worth my approach was to add in this configurable delay after auto-write operations to give the diagnostics time to catch up. Do you think this could work for your use case as well?

Screenshot 2025-01-28 at 12 27 52 AM

@PretzelVector
Copy link
Author

For what it's worth my approach was to add in this configurable delay after auto-write operations to give the diagnostics time to catch up. Do you think this could work for your use case as well?

Actually, there are two different things here:

  • The auto-write delay happens between memory edit and disk save. But Rust Analyzer only starts checking after the file is saved to disk.
  • Some tasks like changing dependencies can be quite slow, while others finish very fast. Better to watch the extension status than make users always wait for fixed delay.

@mrubens
Copy link
Collaborator

mrubens commented Jan 28, 2025

For what it's worth my approach was to add in this configurable delay after auto-write operations to give the diagnostics time to catch up. Do you think this could work for your use case as well?

Actually, there are two different things here:

  • The auto-write delay happens between memory edit and disk save. But Rust Analyzer only starts checking after the file is saved to disk.
  • Some tasks like changing dependencies can be quite slow, while others finish very fast. Better to watch the extension status than make users always wait for fixed delay.

Makes sense, thank you for explaining.

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