microsoft / microsoft/vscode-cpptools

Indentation broken with multiline literal initializer expressions

Open
#9,230 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature: Code Formatting Language Service Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Bug type: Language Service

On Linux with VSCode 1.66.2 and C/C++ Extension Pack 1.1.0, I'm seeing the following:

char **argv = {"foo",<enter>
|

i.e., pressing enter after the first line puts the cursor in column 1, without any indentation. This is wrong, an open brace should result in at least some level of indentation.

Moreover, after manually indenting:

char **argv = {"foo", 
   NULL};<enter>
  |

i.e, now the cursor is indented at the wrong level (since there no longer is any open brace).

Note that selecting the area and formatting it with "Format Selection" gives the correct result.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the multiline literal initializer in VS Code on Linux using the C/C++ extension, then trace the language-service indentation path for Enter and compare it with Format Selection. Confirm that pressing Enter preserves brace-based indentation and does not retain indentation after the closing brace, then add or update regression coverage for both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.