Skip to content

[vcFormat] Extra indentation occurs when passing a struct using compound literal style #14409

@fufu1437

Description

@fufu1437

Environment

  • OS and Version: Arch Linux
  • VS Code Version: 1.117.0
  • C/C++ Extension Version: 1.32.1
  • If using SSH remote, specify OS of remote machine: No

Bug Summary and Steps to Reproduce

Bug Summary:
When passing parameters to a function using a composite font style, if a struct is passed, the indentation position of the first member during initialization meets expectations, but starting from the second member, its indentation unexpectedly increases by one level.

Image

Steps to reproduce:

  1. Define a multi-member struct
  2. Define a function that accepts this struct
  3. Call this function, passing the struct as a compound literal, and assign values to each member of the struct using multiple lines of code.
  4. Call vcFormat to format

Expected behavior:
Starting from the second member, the indentation should be the same as the first member

Image

This is my vcFormat configuration:

Configuration and Logs

settings.json:

{
	"C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyType": true,
	"C_Cpp.vcFormat.newLine.beforeOpenBrace.block": "sameLine",
	"C_Cpp.vcFormat.newLine.beforeOpenBrace.function": "sameLine",
	"C_Cpp.vcFormat.newLine.beforeOpenBrace.lambda": "sameLine",
	"C_Cpp.vcFormat.newLine.beforeOpenBrace.namespace": "sameLine",
	"C_Cpp.vcFormat.newLine.beforeOpenBrace.type": "sameLine",
	"C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyFunction": true,
	"C_Cpp.vcFormat.space.betweenEmptyBraces": true,
	"C_Cpp.vcFormat.newLine.scopeBracesOnSeparateLines": true,
	"C_Cpp.vcFormat.indent.preprocessor": "oneLeft",
	"C_Cpp.vcFormat.space.afterKeywordsInControlFlowStatements": false,
	"C_Cpp.vcFormat.space.pointerReferenceAlignment": "ignore",
	"C_Cpp.vcFormat.indent.caseContentsWhenBlock": true,
	"C_Cpp.vcFormat.indent.caseLabels": true,
	"C_Cpp.formatting": "vcFormat",
}


No additional configuration files are used; this is configuration related to vcFormat

Other Extensions

No response

Additional context

No response

Metadata

Metadata

Assignees

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions