Repository navigation
fix(lsp): organizeImports without resolving specifiers - #31230
Merged
Merged
Conversation
Organize imports action should move, group, or delete imports but not rewrite the imported modules. The current behavior is causing a bug with workspaces, rewriting relative imports to scoped imports if the workspace members are loaded in the server. The two specifiers are not functionally equivalent, at least due to jsr-io/jsr#1220. This change removes the rewriting and keeps the imports as they are sent from tsc. Fixes #31141 [ci]
tugrulates
marked this pull request as ready for review
November 8, 2025 17:18
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug where the "Organize Imports" LSP action was incorrectly rewriting relative imports to scoped imports in workspace scenarios. The fix ensures that import specifiers are preserved as-is from TypeScript, with only their organization (ordering, grouping, deletion) being modified.
- Removes the call to
fix_ts_import_changeswhich was resolving and rewriting import specifiers - Simplifies the code path to directly collect organize imports edits without specifier resolution
- Adds comprehensive test coverage for workspace import organization scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cli/lsp/language_server.rs | Removes the fix_ts_import_changes call that was rewriting import specifiers, replacing it with direct collection of organize imports edits |
| tests/integration/lsp_tests.rs | Adds test case verifying that organize imports preserves relative and scoped imports without rewriting them in workspace scenarios |
π‘ Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bartlomieju
pushed a commit
to bartlomieju/deno
that referenced
this pull request
Nov 17, 2025
bartlomieju
pushed a commit
that referenced
this pull request
Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Organize imports action should move, group, or delete imports but not rewrite the imported modules.
The current behavior is causing a bug with workspaces, rewriting relative imports to scoped imports if the workspace members are loaded in the server. The two specifiers are not functionally equivalent, at least due to jsr-io/jsr#1220.
This change removes the rewriting and keeps the imports as they are sent from tsc.
Fixes #31141