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

Formatting not applied when source file autosaved #548

Closed
bobf32 opened this issue Oct 15, 2024 · 1 comment
Closed

Formatting not applied when source file autosaved #548

bobf32 opened this issue Oct 15, 2024 · 1 comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Issue is not triaged.

Comments

@bobf32
Copy link

bobf32 commented Oct 15, 2024

Diagnostic Data

  • Python version (& distribution if applicable, e.g., Anaconda): 3.12
  • Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): venv
  • Operating system (and version): Win 11 Enterprise
  • Version of tool extension you are using: v2024.4.0

Behaviour

Expected Behavior

With auto save on in VSCode, Black formatting is not applied on auto saves.

Actual Behavior

Nothing. Blaxk formatting only occurs when pressing Ctrl-S.

Reproduction Steps:

Load Python file
Enabled VSCode auto save
Make a change that Black would correct
Observe file is auto saved but no formatting occurs
Press Ctrl-S
Observe Black formatting takes place.

Logs:

2024-10-15 15:06:52.624 [info] [Trace - 3:06:52 PM] Received response 'textDocument/formatting - (2)' in 37ms.
2024-10-15 15:06:52.670 [info] [Trace - 3:06:52 PM] Sending notification 'textDocument/didChange'.
2024-10-15 15:06:58.692 [info] [Trace - 3:06:58 PM] Sending notification 'textDocument/didChange'.
2024-10-15 15:07:01.176 [info] [Trace - 3:07:01 PM] Sending notification 'textDocument/didChange'.
2024-10-15 15:07:03.489 [info] [Trace - 3:07:03 PM] Sending request 'textDocument/formatting - (3)'.
2024-10-15 15:07:03.491 [info] [Trace - 3:07:03 PM] Received notification 'window/logMessage'.
2024-10-15 15:07:03.491 [info] /home/xxxxx/venv_312/bin/python3.12 -m black --stdin-filename /home/xxxxx/python/scratch.py -
2024-10-15 15:07:03.491 [info] [Trace - 3:07:03 PM] Received notification 'window/logMessage'.
2024-10-15 15:07:03.491 [info] CWD formatter: /home/xxxxx/python
2024-10-15 15:07:03.520 [info] [Trace - 3:07:03 PM] Received notification 'window/logMessage'.
2024-10-15 15:07:03.520 [info] reformatted /home/xxxxx/python/scratch.py

All done! ✨ 🍰 ✨
1 file reformatted.

2024-10-15 15:07:03.524 [info] [Trace - 3:07:03 PM] Received response 'textDocument/formatting - (3)' in 35ms.
2024-10-15 15:07:03.570 [info] [Trace - 3:07:03 PM] Sending notification 'textDocument/didChange'.

@bobf32 bobf32 added the bug Issue identified by VS Code Team member as probable bug label Oct 15, 2024
@github-actions github-actions bot added the triage-needed Issue is not triaged. label Oct 15, 2024
@karthiknadig
Copy link
Member

The extension just contributes a formatter. VS Code decides if it should be triggered on autosave or not. The issue here is that VS Code does not trigger formatting on autosave, it triggers it on explicit save.
see here microsoft/vscode#128090 (comment)

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed Issue is not triaged.
Projects
None yet
Development

No branches or pull requests

2 participants