microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.38k stars 28.94k forks source link

Minor indentation inconsistency - trimAutoWhitespace - difference between tab and shift-tab #221444

Open gstavi opened 3 months ago

gstavi commented 3 months ago

Type: Bug

editor.autoIndent = keep editor.trimAutoWhitespace = yes Language: C Indent with tabs tab size = 8

Start state: Cursor at the end of a line: [tab][tab]int x;

All scenarios refer to start state.

Scenario 1: press enter-enter Cursor at indentation at [tab][tab] as expected. Middle line is empty. Auto whitespace trimmed as expected.

Scenario 2: press enter-tab-enter Cursor at indentation at [tab][tab][tab] as expected. Middle line is empty. Our extra tab is considered "auto white space".

Scenario 3: press enter-shift-tab-enter Cursor at indentation at [tab] as expected. Middle line contains a tab. Our shift-tab turn indentation to non-auto.

Scenario 4: press enter-shift-tab-tab-enter Middle line is empty. The tab changed back indentation to auto.

Scenario 5: press enter-tab-shift-tab-enter Middle line has [tab][tab]. The shift-tab changed back indentation to non-auto.

In general it seems that pressing tab maintains line auto-whitespace state while pressing shift-tab revokes the auto-whitespace state. My opinion is that shift-tab should maintain auto whitespace state as well. Maybe even backspace.

VS Code version: Code 1.74.2 (e8a3071ea4344d9d48ef8a4df2c097372b0c5161, 2022-12-20T10:29:14.590Z) OS version: Windows_NT x64 10.0.19045 Modes: Sandboxed: No Remote OS version: Linux x64 6.5.6-300.fc39.x86_64

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (4 x 2112)| |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
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|undefined| |Memory (System)|15.75GB (5.19GB free)| |Process Argv|--crash-reporter-id d3723cdb-8874-46c1-9e7a-40340e035fa3| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|SSH: upstream| |OS|Linux x64 6.5.6-300.fc39.x86_64| |CPUs|Intel(R) Xeon(R) CPU E5-2697 v3 @ 2.60GHz (56 x 1200)| |Memory (System)|251.47GB (248.27GB free)| |VM|0%|
Extensions (7) Extension|Author (truncated)|Version ---|---|--- kconfig|luv|1.0.3 remote-ssh|ms-|0.102.0 remote-ssh-edit|ms-|0.86.0 notepadplusplus-keybindings|ms-|1.0.7 remote-explorer|ms-|0.4.0 cpptools|ms-|1.18.5 code-spell-checker|str|2.20.3
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 chatpanelt:31048053 dsvsc021:30996838 0ee40948:31013168 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 newcmakeconfigv2:31071590 impr_priority:31082723 ```
vscodenpa commented 3 months ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.91.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!