forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
area-formattingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buggood first issueregressionBug didn't exist in a previous releaseBug didn't exist in a previous release
Description
Environment data
- VS Code version: 1.44.2
- Extension version (available under the Extensions sidebar): master
- OS and version: windows 10
- Python version (& distribution if applicable, e.g. Anaconda): 3.8
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
- Relevant/affected Python packages and their versions: black
- Relevant/affected Python-related VS Code extensions and their versions: N/A
- Jedi or Language Server? (i.e. what is
"python.jediEnabled"set to; more info How to update the language server to the latest stable version #3977): false - Value of the
python.languageServersetting: Microsoft
Expected behaviour
Should format document.
Actual behaviour
Formatting fails to apply.
Steps to reproduce:
- Create a python file with blank first line:
import sys
print(sys.executable)Reason
From the logs:
Formatting with black failed.
TypeError: Cannot read property 'length' of undefined
This issue is caused in getTextEditsInternal. When the first line is blank, start.line is 0. beforeLines[start.line - 1].length === 0 check fails with TypeError: Cannot read property 'length' of undefined
makinori, Gonzalo933, CR-OmerYampel, nathanrpage97, mrabedini and 9 more
Metadata
Metadata
Assignees
Labels
area-formattingbugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable buggood first issueregressionBug didn't exist in a previous releaseBug didn't exist in a previous release