-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Auto formatting of document+imports racing condition? #2301
Comments
This is a side-effect of |
Hi @brettcannon, Since VSCode team think it's not for VSCode to fix, and you're saying it can't be solved here, where should I direct my request / bug report? |
I'm saying I don't think it can necessarily be fixed at all. Basically you either need isort to output in a format that black likes (so black no longer care, have black sort imports (so you don't need isort), or trigger the import sorting manually (so you remove the race condition). I've also followed up on the VS Code issue to try and get more info on how they handle this situation for JavaScript. |
So it's not possible to say "Sort imports" should finish running before any formatters are allowed to run? VSCode don't give that capability?
Good idea. There could potentially be the same issues between any import organizer they use, and a system like prettier. |
@gandalfsaxe Correct, VS Code doesn't let us say "please run this before that". All we get is "sort imports" and "format document" calls and both are done via callbacks which we don't directly trigger. |
Issue Type: Bug
I use the following settings:
However the imports formatting is very inconsistent. Sometimes it follows
black
, and most times it doesn't. Any multi-line imports where each imported variable/function should be on it's own line (according toblack
) often isn't.If I run
Format Document
, it formats the imports according to black (one per line):If I run
Organize Imports
, it puts everything on as few lines as possible (violates black):And worst of all, it seems like VSCode is alternating between these two outcomes
Since it sometimes work, it seems as if there is a racing condition between the
Format Document
command andOrganize Imports
command when both are auto enabled on save in settings. The right thing to do would seem to first run the ordinary import formatting, then run any custom formatting provider afterwards.Since this looks like a bug / conflict between the "Format Document" and "Organize Imports" commands., which are both build-in, I think this is a VSCode problem, not vscode-python extension problem.
VS Code version: Code - Insiders 1.26.0-insider (573d53815e74f8e4a52c2b6665f5ba9a92dbd341, 2018-08-01T05:17:54.216Z)
OS version: Windows_NT x64 10.0.15063
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Extensions (33)
(2 theme extensions excluded)
The text was updated successfully, but these errors were encountered: