Open bersbersbers opened 1 year ago
Version: 1.73.1 (user setup) Commit: 6261075646f055b99068d3688932416f2346dd3b Date: 2022-11-09T04:27:29.066Z Electron: 19.0.17 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Windows_NT x64 10.0.19044 Sandboxed: No
isort v2022.8.0
Name: isort
Module: isort
Python extension loading
Waiting for interpreter from python extension.
Python extension loaded
CWD Server: c:\Code\project
sys.path used to run Server:
c:\Users\bers\.vscode\extensions\ms-python.isort-2022.8.0\bundled\tool
C:\Users\bers\.pyenv\pyenv-win\versions\3.11.0\python311.zip
C:\Users\bers\.pyenv\pyenv-win\versions\3.11.0\DLLs
C:\Users\bers\.pyenv\pyenv-win\versions\3.11.0\Lib
C:\Users\bers\.pyenv\pyenv-win\versions\3.11.0
c:\Users\bers\.pyenv-win-venv\envs\project_dev
c:\Users\bers\.pyenv-win-venv\envs\project_dev\Lib\site-packages
c:\Users\bers\.vscode\extensions\ms-python.isort-2022.8.0\bundled\libs
Settings used to run Server:
[
{
"check": false,
"workspace": "file:///c%3A/Code/project",
"logLevel": "error",
"args": [],
"severity": {
"W": "Warning",
"E": "Hint"
},
"path": [],
"interpreter": [
"c:\\Users\\bers\\.pyenv-win-venv\\envs\\project_dev\\Scripts\\python.exe"
],
"importStrategy": "fromEnvironment",
"showNotifications": "off"
}
]
c:\Users\bers\.pyenv-win-venv\envs\project_dev\Scripts\python.exe -m isort --version-number
CWD Linter: c:\Code\project
Version info for isort running for c:\Code\project:
5.10.1
SUPPORTED isort>=5.10.1
FOUND isort==5.10.1
This does not happen with only the black extension installed:
So this means this is an issue of some extension, and not VS Code? Looks like a formatter issuer.
This does not happen with only the black extension installed:
So this means
Just to avoid confusion: this happens with isort, but not with black alone. I just noticed my statement above is easy to misread.
this is an issue of some extension, and not VS Code?
It may well be.
Looks like a formatter issuer.
That's what I thought initially. Not sure why this issue was transferred here.
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. If you don't know which extension is causing the problem, you can run Help: Start extension bisect
from the command palette (F1) to help identify the problem extension.
Happy Coding!
@brettcannon since you seem to have transferred this issue here - do you have a reason to believe this is not caused by the isort extension?
@bersbersbers The isort extension only does import sorting, so I didn't see how that would cause anything to occur when viewing a diff since it doesn't participate in diff views in any way.
You can also save in diff editors which will trigger a format. The cursor position might change when you get the entire value, modify it and set the entire value.
You can also save in diff editors
Yes, this is exactly what I am doing. Sorry if that hasn't become clear from my bug description above.
I'm still not sure if there's anything we can do here based on how isort works, but I will re-open the issue in case there is.
My first instinct was to say that maybe it is helpful to consider that the same thing does not happen with the black
extension. After all, both seem to receive a complete file and return a complete, formatted file.
But note that I am almost completely unfamiliar with the way these two tools interface with VS Code extensions - and looking at how different these two interfaces appear, I can understand this is not obvious.
https://github.com/microsoft/vscode-isort/blob/ef37d377cab60abb0a25ce983b6b6591d186aec0/bundled/tool/utils.py#L110-L132 vs. https://github.com/microsoft/vscode-black-formatter/blob/c63f4d1a002764df712823e95c9b37541d2a14d0/bundled/tool/utils.py#L146-L159
Good luck, anyway!
This seems to happen in diff views only, so to reproduce, create an empty Git repo, create a new file, and open it by double-clicking in Source Control.
Before saving:
After saving:
This does not happen with only the
black
extension installed:Before:
After: