microsoft / microsoft/vscode-cpptools

Weird behaviour with vcFormat and lambdas

Open
#9,800 3 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

Environment
  • OS and Version: windows 10
  • VS Code Version: 1.69.2
  • C/C++ Extension Version: 1.11.5
  • Other extensions you installed (and if the issue persists after disabling them):
  • If using SSH remote, specify OS of remote machine: No ssh
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc): vcFormat makes lamdbas in function calls inside function calls weird
Bug Summary and Steps to Reproduce

Bug Summary:
with these settings
"C_Cpp.formatting": "vcFormat"
"C_Cpp.vcFormat.indent.lambdaBracesWhenParameter": true
"C_Cpp.vcFormat.indent.multiLineRelativeTo": "innermostParenthesis"
every other setting is default
also when C_Cpp.vcFormat.indent.multiLineRelativeTo is set to both it's other parameters

Expected behavior

No response

Code sample and Logs
template<typename... Ts>
void a_function(Ts...){

}

template<typename T>
T another_function(T t){
    return t;
}

int main(){
    //before formatting
    a_function(
        another_function([]() {
            return 1;
        }),
        another_function([]() {
            return 2;
        }),
        another_function([]() {
            return 3;
        }),
        another_function([]() {
            return 3;
        }),
        another_function([]() {
            return 3;
        }),
        another_function([]() {
            return 3;
        })
    );
    //after formatting
    a_function(
        another_function([]() {
            return 1;
            }),
        another_function([]() {
                return 2;
            }),
                another_function([]() {
                return 3;
                    }),
                another_function([]() {
                        return 3;
                    }),
                        another_function([]() {
                        return 3;
                            }),
                        another_function([]() {
                                return 3;
                            })
                                );
 
}
Screenshots

image

Additional context

No response

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

Start by reproducing the report in the issue's Windows 10, VS Code 1.69.2, and C/C++ extension 1.11.5 setup using the supplied C++ sample and vcFormat settings. Compare the formatter's output for nested lambdas under each multiLineRelativeTo option; done means the output no longer develops inconsistent indentation and matches the intended lambda-brace setting.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.