Skip to content

Tab key when indenting with spaces does not insert correct number of spaces #80129

Closed

Description

Issue Type: Bug

Related to #2798.

Suppose I have a line of Python in a space-indented file like this:

    do_something()

I want to wrap it in a conditional, so I add a line above it:

    if condition:
    do_something()

Now I need to indent the body of the conditional, so I click somewhere in the whitespace to the left of that line, and press Tab:

    if condition:
     do_something()

It only inserts one space, awkwardly leaving the line with 5 space indentation when the file is set to use 4 spaces per tab.

Why? Because it only looks at the column position of the cursor when deciding how many spaces to insert, and not the total number of contiguous space characters there are.

This is almost certainly never what a programmer wants.

VS Code version: Code 1.37.1 (f06011a, 2019-08-15T16:16:34.800Z)
OS version: Darwin x64 18.7.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz (8 x 2700)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
oop_rasterization: disabled_off
protected_video_decode: unavailable_off
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) 2, 2, 2
Memory (System) 16.00GB (0.07GB free)
Process Argv -psn_0_167977
Screen Reader no
VM 0%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    *caused-by-extensionIssue identified to be caused by an extension

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions