Registry Mirror
Skip to content

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Organize imports merges declarations whose attributes produce the same key. The key wrote attribute names and values without escaping, so an attribute value containing quotes could collide with a different set of attributes, and imports with different attributes were merged.

This test records organize imports for two imports whose attributes
differ only in where a quoted value ends.
Organize imports merges declarations whose attributes produce the same
key. The key wrote attribute names and values without escaping, so an
attribute value containing quotes could collide with a different set
of attributes, and imports with different attributes were merged.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are recorded for the import-attribute grouping fix.

No open issues 🎉

What changed in this PR

Fixes incorrect merging of imports with distinct attributes in the language server’s organize-imports feature.

Changes:

  • Quotes and escapes attribute names and string values when building grouping keys.
  • Adds a regression test for an attribute value containing embedded quotes.
File Description
tsc/​internal/​ls/​organizeimports.go Uses strconv.Quote to prevent attribute-key collisions.
tsc/​internal/​fourslash/​tests/​organizeImportsAttributes4_test.go Verifies imports with different attributes remain separate.

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants