Repository navigation
Move the "Add Dependency" fix to middleware - #6062
Conversation
This should fix the race that could cause it appear at the bottom instead of the top. Fixes #5968
There was a problem hiding this comment.
Code Review
This pull request integrates the AddDependencyCodeActionProvider directly into the LSP analyzer's provideCodeActions middleware rather than registering it as a separate VS Code code action provider. This ensures custom dependency fixes are stitched in at the top of the results. One issue was identified where using the spread operator inside push on a potentially large array could lead to a stack overflow, and it is recommended to use concat instead.
There was a problem hiding this comment.
Pull request overview
This PR addresses a race in Quick Fix ordering by moving the custom “Add dependency” fix integration into the LSP middleware, ensuring it appears before server-provided fixes like “Ignore”.
Changes:
- Remove delayed VS Code registration of
AddDependencyCodeActionProviderfrom extension activation. - Instantiate and invoke
AddDependencyCodeActionProviderinside LSPprovideCodeActionsmiddleware and prepend its results. - Update the provider’s
provideCodeActionssignature to return(Command | CodeAction)[]to align with LSP/middleware usage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/extension/providers/add_dependency_code_action_provider.ts |
Adjusts provider API typing to support being invoked from middleware. |
src/extension/extension.ts |
Removes delayed provider registration logic previously used to influence ordering. |
src/extension/analysis/analyzer.ts |
Adds middleware stitching to insert custom “Add dependency” fixes at the top of LSP code actions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6062 +/- ##
==========================================
- Coverage 70.49% 70.47% -0.02%
==========================================
Files 171 171
Lines 12981 12983 +2
Branches 2591 2592 +1
==========================================
- Hits 9151 9150 -1
- Misses 3343 3345 +2
- Partials 487 488 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This should fix the race that could cause it appear at the bottom instead of the top.
Fixes #5968