You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The given example might seem like silly code to write, so here's some background:
I have the "Organize Imports" action and Prettier configured to run on save in VSCode. I was debugging something in a file with many imports and was commenting/uncommenting large blocks of code, but kept annoyingly losing imports after commenting stuff out, which meant I had to manually bring them back when uncommenting.
As a quick workaround I wrote this at the top of the file:
import{a,b,c,d}from'./something.js'// TODO: remove this; it's here to preserve imports[a,b,c,d]
Which Prettier turns into this (because I use "semi": false):
import{a,b,c,d}from'./something.js'// TODO: remove this; it's here to preserve imports;[a,b,c,d]
Which Organize Imports turns into this:
import{a,b,c,d}from'./something.js';[a,b,c,d]
What's extra annoying about this is that Prettier runs after Organize Imports, so what actually happens is the first time I save the file I just get the semicolon added, and then the second time I save the file (without making any changes) the comment vanishes.
If this bug realistically only affects people with this specific setup then I can understand if it's not prioritized, but it seemed worth opening an issue in any case.
π Search Terms
source.organizeImports, VSCode, "source action", semicolon, remove, change
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAcgM4RAUxgC2AOwOYIBQA9MXAMaro4yEDcQA
π» Code
π Actual behavior
When organizing inputs in the given file, the output is this:
π Expected behavior
I expected the comment to be preserved.
Additional information about the issue
The semicolon is important here. Without it the comment is preserved.
#48126 is perhaps tangentially related.
The text was updated successfully, but these errors were encountered: