withastro / language-tools

Language tools for Astro
MIT License
270 stars 54 forks source link

🐛 BUG: Adding duplicate import statement when using CRLF line endings and organize imports #933

Closed xkeshav closed 3 months ago

xkeshav commented 3 months ago

Describe the Bug

Whenever we save an .astro file; it automatically add the last import statment one more time. earlier I though it is due to some eslint and vd code settings. here is full details of issue.

Astro extension v v2.13.2

VS Code v 1.92

VS Code > About Report

Version: 1.92.1
Commit: eaa41d57266683296de7d118f574d0c2652e1fc4
Date: 2024-08-07T20:16:39.455Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Linux x64 6.8.0-40-generic

.prettierrc.js is default formatter and .eslintrc.js is on place

Steps to Reproduce

Please see here for details

Link to Minimal Reproducible Example

https://github.com/withastro/prettier-plugin-astro/issues/425

Princesseuh commented 3 months ago

This should normally already been fixed, see https://github.com/withastro/language-tools/issues/928

I cannot reproduce the issue with your snippet, so there must be something else going on... Could you share a repo?

Princesseuh commented 3 months ago

Managed to reproduce, it only happens in prod and with CRLF line endings again...

Princesseuh commented 3 months ago

Figured it out, there was an update to an upstream dependency that unexpectedly caused a change in how we generate the Volar mappings https://github.com/microsoft/vscode-languageserver-node/pull/1286

I'm not sure if Microsoft intended for it to be breaking or not, but a bit annoying. It only happened in prod because prod ended up using a different version of the dependency due to a difference between how pnpm and npm handled the dep.

xkeshav commented 3 months ago

But it is happening in a dev environment too

Princesseuh commented 3 months ago

Should be fixed in latest version of the extension!