Skip to content

Saving changes to Python files with 'Format On Save' occasionally leads to duplicating the last few lines or symbols (using Black Formatter) #604

@kirilllzaitsev

Description

@kirilllzaitsev

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version:
Version: 1.107.1
Commit: 994fd12f8d3a5aa16f17d42c041e5809167e845a
Date: 2025-12-17T14:15:14.850Z
Electron: 39.2.3
ElectronBuildId: 12895514
Chromium: 142.0.7444.175
Node.js: 22.21.1
V8: 14.2.231.21-electron.0
OS: Linux x64 6.8.0-90-generic
  • OS Version: Ubuntu 22.04

Example. The last two lines on the screenshot were duplicated twice over multiple Save+Format on save executions:

Image

Steps to Reproduce:

  1. Create a Python file with some code
  2. Save with format-on-save (e.g., Black) multiple times (might require some violation of the PEP8 style to take effect)
  3. Observe new statements (valid or invalid) appear at the end of the file

The issue has been there for a few months.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions