pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Incorrect function argument indentation

Open CendioOssman opened this issue 1 year ago • 4 comments
trafficstars

Type: Bug

Behaviour

Expected vs. Actual

When continuing a functional call on a new line, the new line fails to line up correctly with the preceeding line.

def foo():
	incorrect_indentation(a, b, c,
					   d, e, f)
	correct_indentation(a, b, c,
	                    d, e, f)

Steps to reproduce:

  1. Enable tabs for indentation
  2. Try to type out the above code

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.7
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX
User Settings


languageServer: "Pylance"

Extension version: 2024.0.1 VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:19.222Z) OS version: Linux x64 6.6.9-100.fc38.x86_64 Modes:

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 x 4299)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 3, 3, 3
Memory (System) 15.45GB (1.08GB free)
Process Argv /local/home/ossman/devel/thinlinc --crash-reporter-id dbaf113b-c334-41e0-b6ea-63700be50a3b
Screen Reader no
VM 0%
DESKTOP_SESSION gnome-xorg
XDG_CURRENT_DESKTOP GNOME
XDG_SESSION_DESKTOP gnome-xorg
XDG_SESSION_TYPE x11
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscoreces:30445986
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
accentitlementsc:30887149
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
pydisww2:30959801
dsvsc019bcf:30953938
3ef8e399:30949928
ccp2r3:30958157

CendioOssman avatar Feb 09 '24 13:02 CendioOssman

Note that there are two issues here:

  1. It incorrectly calculates how many tabs and spaces are needed
  2. It should not use any tabs at all for character alignment. It should use tabs for the nesting level, then spaces to align with the text on the line above. Otherwise, the alignments start depending on tab size and will get messed up if opened in an editor with a different tab size. In the above example, that would mean one tab followed by 22 spaces.

CendioOssman avatar Feb 09 '24 13:02 CendioOssman

Thanks for the report. I am able to repro this and I agree with your description of the correct behavior.

debonte avatar Feb 09 '24 21:02 debonte

If I understand things correctly, this is handled by Pylance rather than the Python extension?

Is the relevant part open source, if I'd like to attempt to resolve the issue myself?

CendioOssman avatar Feb 12 '24 16:02 CendioOssman

Yes, this is a bug in Pylance. No, it is not open source.

debonte avatar Feb 12 '24 16:02 debonte