Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode shifts errors underlining when Perttier's multiline import formatting applies #70854

Closed
dimikot opened this issue Mar 20, 2019 · 6 comments
Assignees
Labels
editor-contrib Editor collection of extras info-needed Issue requires more information from poster

Comments

@dimikot
Copy link

dimikot commented Mar 20, 2019

Not quite clear, is it a bug in VSCode or in Prettier, but I bet 90% it's in VSCode, because it's VSCode who highlights errors in the text.

There is a bug somewhere when builtin VSCode's source.organizeImports feature is used together with Prettier (and probably with any other extension which rewrites the text). People sometimes prefer to use VSCode's built-in source.organizeImports feature ON SAVE which, among other things, places all imports on the same line. And this conflicts with Prettier when it formats imports at multiple lines: if there is an error in the code, the underlining of this error shifts towards beginning of the file.

I recorded a video which shows the effect, pretty easy to reproduce:
https://www.dropbox.com/s/apj5znzlqy8pub6/vscode-prettier.mp4?dl=0

  • VSCode Version: 1.32.3
  • OS Version: MacOS Mojave 10.14.3

Steps to Reproduce:

  1. Install Prettier, turn on "editor.codeActionsOnSave": { "source.organizeImports": true } in settings.json.
  2. Open a file with a big number of imports and an error in the file and reproduce what's shown on the video. When you hit Save, and there is an error, its underlining shifts left on every save and messes everything up.

Does this issue occur when all extensions are disabled? No

Corresponding issue at Prettier: prettier/prettier#5995

@vscodebot vscodebot bot added the editor-contrib Editor collection of extras label Mar 20, 2019
@jrieken
Copy link
Member

jrieken commented Mar 21, 2019

built-in source.organizeImports feature ON SAVE which, among other things, places all imports on the same line.

Putting things on one line isn't what we do. I bet that this is an extension issue but I leave it to @mjbvz who works on code-actions-on-save

@jrieken jrieken assigned mjbvz and unassigned jrieken Mar 21, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Mar 21, 2019

Does this reproduce in the latest VS Code insiders build?

@dimikot
Copy link
Author

dimikot commented Mar 21, 2019

Putting things on one line isn't what we do

I meant not everything on one line, but each individual import statement (i.e. all symbols related to one import) on the same line. Different import statements are still on different lines while using organizeImports.

But it all doesn’t quite matter, this bug report is about error underlining shifting, not about organizeImports nor prettier. I mentioned organizeImports and prettier only to show how to reproduce the bug.

I will try the latest vscode insiders build.

@jrieken
Copy link
Member

jrieken commented Mar 22, 2019

this bug report is about error underlining shifting,

Where do those errors come from? After the error message we show something like ts(1182) or tslint(7). Please check with those, stale, errors

@mjbvz mjbvz added the info-needed Issue requires more information from poster label Apr 6, 2019
@mjbvz
Copy link
Contributor

mjbvz commented Apr 6, 2019

@DmitryKoterov Did you have a chance to try on the latest builds?

@mjbvz
Copy link
Contributor

mjbvz commented Apr 29, 2019

Closing as more information is needed to investigate this issue

@mjbvz mjbvz closed this as completed Apr 29, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-contrib Editor collection of extras info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

3 participants