Repository: vscode
Issue: Weird code indentation C++
Labels: editor-autoindent,under-discussion,c++,on-unit-test


Issue Type: <b>Bug</b>

Hi there!

I have such piece of code (code indentation is 4 spaces):
```C++
int WINAPI WinMain(::HINSTANCE instance, ::HINSTANCE prev_instance,
    char *cmdline, int nshowcmd) {}
```
And I get weird indentation when I put my cursor between curly braces and press Enter:
```C++
int WINAPI WinMain(::HINSTANCE instance, ::HINSTANCE prev_instance,
    char *cmdline, int nshowcmd) {
        // weird caret position (8 spaces from the beginning of the line)
    } // weird brace position (4 spaces from the beginning of the line)
```
But I would expect
```C++
int WINAPI WinMain(::HINSTANCE instance, ::HINSTANCE prev_instance,
    char *cmdline, int nshowcmd) {
    // expected caret position
} // expected brace position
```
Now with the second piece of code, if I put my cursor after opening curly brace and hit enter, my cursor gets to this weird position:
```C++
int WINAPI WinMain(::HINSTANCE instance, ::HINSTANCE prev_instance,
    char *cmdline, int nshowcmd) { // 1. I'm here, pressing Enter
        // 2. my caret is here (8 spaces from the beginning of the line)
    // !. But it should be here (4 spaces from the beginning of the line)
}
```
It seems like it applies my indentation rules (4 spaces), but the code gets aligned to `char* cmdline`. So I always have to fix it manually. What should I do so that it will indent in expected way?

I'm using clang-format:
```
---
BasedOnStyle:  Google
IndentWidth: 4
SortIncludes: Never
AllowShortCaseLabelsOnASingleLine: true
IndentCaseBlocks: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AlignAfterOpenBracket: DontAlign

```

VS Code version: Code 1.67.1 (da15b6fd3ef856477bf6f4fb29ba1b7af717770d, 2022-05-06T12:37:03.389Z)
OS version: Windows_NT x64 10.0.19045
Restricted Mode: No

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|AMD Ryzen 7 5700U with Radeon Graphics          (16 x 1797)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: disabled_off<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>oop_rasterization: enabled<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_renderer: enabled_on<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|14.82GB (6.62GB free)|
|Process Argv|. --crash-reporter-id 01a67f4c-d55c-40f4-b58a-c4b2f80741d9|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (13)</summary>

Extension|Author (truncated)|Version
---|---|---
markdown-mermaid|bie|1.15.3
vscode-glsllint|dto|1.8.0
go|gol|0.38.0
mesonbuild|mes|1.7.1
python|ms-|2022.8.1
vscode-pylance|ms-|2023.1.10
nas-vscode|rig|0.0.1
rust-analyzer|rus|0.3.1443
shader|sle|1.1.5
cmake|twx|0.0.17
vim|vsc|1.24.3
clang-format|xav|1.9.0
markdown-all-in-one|yzh|3.5.0

(2 theme extensions excluded)

</details>
<!-- generated by issue reporter -->