Format with "editor.formatOnSaveMode": "modificationsIfAvailable"
introduces newlines
#521
Labels
"editor.formatOnSaveMode": "modificationsIfAvailable"
introduces newlines
#521
Diagnostic Data
Id: ms-python.black-formatter
Description: Formatting support for Python files using the Black formatter.
Version: 2024.2.0
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
Behaviour
Expected Behavior
The save behaviour should not affect how the file is formatted.
Actual Behavior
With the setting "modificationsIfAvailable" in format on save mode, and the code:
making a change to the constructor line only will cause an extra line to be inserted between
class App
anddef __init__
on save. A "black format" of the whole file does not introduce this line, only if theclass App:
is unmodified anddef __init__
is modified, and then a save action takes place.Reproduction Steps:
Set the setting as above; make and commit the file to source control without the newline. Make a trivial edit to the
def __init__
line and save.Logs:
Click here for detailed logs
2024-06-21 16:33:21.302 [info] /home/mgodbolt/dev/tradewinds/out/env/bin/python3 -m black --line-ranges 15-15 --line-ranges 18-18 --line-ranges 38-38 --line-ranges 42-43 --line-ranges 60-61 --line-ranges 124-124 --line-ranges 138-138 --line-ranges 140-142 --line-ranges 263-263 --line-ranges 277-277 --line-ranges 302-303 --line-ranges 304-304 --line-ranges 312-315 --stdin-filename /home/mgodbolt/dev/tradewinds/src/py/tradewinds/porthole/apps.py - 2024-06-21 16:33:21.303 [info] CWD formatter: /home/mgodbolt/dev/tradewinds 2024-06-21 16:33:21.392 [info] reformatted /home/mgodbolt/dev/tradewinds/src/py/tradewinds/porthole/apps.pyAll done! ✨ 🍰 ✨
1 file reformatted.
Outcome When Attempting Debugging Steps:
Did running it from the command line work? No - command seems to want to read from stdin and so hung when I tried to run it as described above.
Extra Details
n/a
The text was updated successfully, but these errors were encountered: