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

organizeImports duplicates and removes code (destroys syntax) #89984

Closed
Spenhouet opened this issue Feb 4, 2020 · 3 comments
Closed

organizeImports duplicates and removes code (destroys syntax) #89984

Spenhouet opened this issue Feb 4, 2020 · 3 comments
Labels
*caused-by-extension Issue identified to be caused by an extension

Comments

@Spenhouet
Copy link

Two issues:

  • Unstable / inconsistent formatting - Formatting changes with every save
  • Removes or duplicates code - Destroys code base and syntax

Steps to Reproduce:

  1. Use the following setting:
{
    "[python]": {
        "editor.codeActionsOnSave": {
            "source.organizeImports": true,
        }
    }
}
  1. Open a python file
  2. Enter the following import
from utils.python_utils import (CaseInsensitiveDict, CaseInsensitiveKey, CaseInsensitiveSet,
                                UpperLowerBound)
  1. Press save

Result

You will either get this (duplicated and destroyed code):

from utils.python_utils import (CaseInsensitiveDict, CaseInsensitiveKey,
                                CaseInsensitiveSet, UpperLowerBound)
    UpperLowerBound)

or that:

from utils.python_utils import (CaseInsensitiveDict, CaseInsensitiveKey,
                                CaseInsensitiveSet, UpperLowerBound)  

Expected Result

Nothing changes.
No imports need to be sorted. Everything is sorted.
The import was already formatted correctly.

This is really bad. If this happens the first time, saving a second time will be very destructive to your code. It will start duplicating and deleting other lines in your file.

Environment:

  • VSCode Version: 1.41.1
  • OS Version: Windows 10 (build 1909)
@eamodio eamodio added the *caused-by-extension Issue identified to be caused by an extension label Feb 4, 2020
@vscodebot
Copy link

vscodebot bot commented Feb 4, 2020

This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the marketplace for VS Code. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed Feb 4, 2020
@eamodio
Copy link
Contributor

eamodio commented Feb 4, 2020

Please open an issue for the Python extension.

@Spenhouet
Copy link
Author

Thanks for the redirect. I opened an issue here: microsoft/vscode-python#9889

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*caused-by-extension Issue identified to be caused by an extension
Projects
None yet
Development

No branches or pull requests

2 participants