Skip to content

[Astro VS CODE] source.organizeImports is still broken #18638

Closed

Description

@Eptagone

Astro Info

❯  pnpm exec astro info                       
Astro                    v7.4.5
Node                     v26.13.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

The same issue #17909 is still happening

What's the expected result?

See #17909

Link to Minimal Reproducible Example

https://github.com/Eptagone/astro-vscode-sort-imports

Participation

  • I am willing to submit a pull request for this issue.

Activity

  1. added
    triage: in progress
    on Nov 5, 2026
  2. astro-factory commented on Nov 5, 2026

    @astro-factory
    Contributor

    Triage complete

    • Prepare the workspace: ready
    • Install dependencies: complete
    • Build the project: complete
    • Reproduce the issue: confirmed
    • Diagnose the cause: high confidence
    • Verify the diagnosis: bug
    • Attempt a fix: verified
    • Publish the result: set triage: needs triage

    • Reproduced: Yes, with the published VS Code extension (2.16.20). It does not reproduce when the extension is built from current main.
    • Exploration: Yes — View branch
    • Unit Test: No. The existing packages/language-tools/language-server/test/typescript/organize-imports.test.ts already covers this and passes. The problem is in releasing, which a unit test can't check.
    • Priority: P3: minor bug. Organize-imports-on-save only handles one region of .astro files that have both frontmatter and <script> tags. Everything else in the extension works.

    The #17909 fix (#17916) is on main, but it never reached the VS Code Marketplace or Open VSX. The extension versions that include it (astro-vscode 2.17.0–2.17.2) went to npm, but both stores still stop at 2.16.20, which is older than the fix. After the Changesets v3 migration (#17856), the release workflow's VS Code publish step depended on a changesets/action output that no longer worked as expected, so it was skipped. #18104 fixed the workflow later, but astro-vscode hasn't had a new version since then.

    I found a potential fix for this issue. It doesn't change any code: it adds a patch changeset for astro-vscode (.changeset/chilly-lemons-go.md), so the next release publishes 2.17.3 through the fixed workflow. A maintainer could also publish 2.17.2 to the stores by hand. This needs human review, especially to check that the vsce/ovsx publish steps and their tokens still work.

    Full Triage Report

    Issue

    "[Astro VS CODE] source.organizeImports is broken again". The reporter says #17909 is happening again. Environment: Astro 7.4.5, Node 26.13.0, macOS arm64, pnpm, VS Code with astro-build.astro-vscode. Repro: https://github.com/Eptagone/astro-vscode-sort-imports. It uses editor.codeActionsOnSave: { "source.organizeImports": "explicit" } on an .astro file that has imports in the frontmatter and in a <script>.

    What #17909 was

    #17916 (8eaa4f21e) fixed it, changeset: "Fixes organize imports across frontmatter and multiple script tags". Volar's @volar/language-service withCodeAction dedupes code actions by title only. Each TypeScript region of an .astro file (the frontmatter and each <script>) returns its own action titled "Organize Imports", so all but one were dropped. The fix is a pnpm patch that adds JSON.stringify(item.data) to the dedupe key: patches/@volar__language-service@2.4.30.patch, registered in pnpm-workspace.yaml under patchedDependencies.

    Reproduction

    I drove the language server over LSP with the existing test harness (language-server/test/server.ts). I sent source.organizeImports for the whole document (triggerKind 2, as on save) and for a cursor position, using the reporter's file with unused pooServer / pooClient imports added:

    Server Actions returned Regions fixed
    Language server built from main 2 frontmatter + script
    VS Code extension bundle built from main (pnpm -C packages/language-tools/vscode build) 2 frontmatter + script
    Published extension 2.16.20 (Marketplace vsix) 1 only the script; pooServer is left in the frontmatter

    The 2.16.20 bundle contains the unpatched dedupe (e=>[e.title]). organize-imports.test.ts passes 6/6 on main.

    Diagnosis

    Verification

    This is a bug (high confidence). Maintainers chose the expected behaviour explicitly in #17916, with a changeset and tests. Missing the store releases was accidental, as the later workflow fixes show.

    Fix

    I added .changeset/chilly-lemons-go.md:

    ---
    'astro-vscode': patch
    ---
    
    Publishes the Astro VS Code extension with the fix for `source.organizeImports` only organizing imports in one region of `.astro` files that have both frontmatter and `<script>` tags
    • pnpm changeset status shows astro-vscode -> 2.17.3. The current workflow will detect that version bump and run vsce publish / ovsx publish.
    • No source changes; git diff packages/ is empty.
    • Alternative: publish 2.17.2 to the stores by hand.
    • Note: the fix depends on a pnpm patch to Volar pinned to @2.4.30. Future Volar upgrades must carry the patch forward, and it may be worth upstreaming.

    This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.

  3. added
    - P3: minor bug
    pkg: language-tools
    triage: needs triage
    and removed
    triage: in progress
    on Nov 5, 2026
  4. changed the title [-][Astro VS CODE] source.organizeImports is broken again[/-] [+][Astro VS CODE] source.organizeImports is still broken[/+] on Nov 6, 2026
  5. Princesseuh commented on Nov 11, 2026

    @Princesseuh
    Member

    Release is out and should normally have the fix

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

Metadata

Metadata

Assignees

Labels

- P3: minor bugpkg: language-toolstriage: needs triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions