Skip to content

Wrong indentationRules for single line block in C/C++ #243638

@CendioOssman

Description

@CendioOssman

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: code-1.98.1-1741624570.el8.x86_64
  • OS Version: Red Hat Enterprise Linux release 9.5 (Plow)

Steps to Reproduce:

if (foobar)<enter>

Cursor is now at the same indentation as if, not one step indented.

or

if (foobar)
    do_something();

Put the cursor at the start of do_something(); and paste a line. End result:

if (foobar)
pasted();
do_something();

#209802 seems to discuss the same issue, but for JavaScript/TypeScript. And in that language things seem to behave much more sane with the current version of vscode.

As noted on that issue, it's important to also consider the style:

if (foobar)
{
    do_something();
}

The solution implemented for JavaScript is that you get an automatic indentation after if (foobar), then it un-indents when you type the {. The same behaviour would be ideal for C/C++ (and likely all C inspired languages).

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bugc++C++ support issueseditor-autoindentEditor auto indentation issueseditor-clipboardEditor clipboard issuesinsiders-releasedPatch has been released in VS Code InsidersverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions