microsoft / microsoft/vscode-cpptools

VcFormat setting C_Cpp.vcFormat.indent.lambdaBracesWhenParameter:true not respected when lambda has non trivial capture

Aperta
#8,382 5 commenti 5 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Feature: Code Formatting Language Service more votes needed Visual Studio
Lingua principale
TypeScript
Stelle
6.2k
Fork
1.7k
Merge medio
14h 46m
PR unite (30g)
61

Descrizione

lmabda_indent
Bug type: Language Service

Describe the bug

If a lambda used as a parameter to a function has a capture list with an non trivial assignment, [q = p + 1], the lambda body is not indented properly. "C_Cpp.vcFormat.indent.lambdaBracesWhenParameter": true is the default value, so it is expected that parameter lambdas have their bodies indented.

  • OS and Version: Ubuntu 18.04.6
  • VS Code Version: 1.61.2
  • C/C++ Extension Version:1.7.1
  • Other extensions you installed (and if the issue persists after disabling them): all other extensions are disabled

Steps to reproduce

  1. Ensure vcFormat is the cpp formatter
  2. format code in the sample below

Expected behavior

parameter lambdas that have non trivial capture lists should be indented relative to the function in which they are a parameter

Code sample and logs

#include <future>

void test()
{
    int q = 1;
    int p = 8;

    std::async(
        [q]() mutable
        {
            // indented
        });

    std::async(
        [q = p + 1]()
    {
        // not indented
    });
}

Configurations in c_cpp_properties.json
n/a

settings.json

{
    "C_Cpp.formatting": "vcFormat"
}

By the way there is a similar (opposite?) bug in visual studio, not sure if it's relevant:
https://developercommunity.visualstudio.com/t/visual-studio-may-indent-lambda-braces-despite-for/1004592

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l'esempio C++ fornito e con l'impostazione C_Cpp.formatting configurata su vcFormat, quindi confronta la formattazione delle catture lambda semplici e non banali. Il lavoro è completato quando i lambda parametro con elenchi di catture non banali hanno i propri corpi indentati rispetto alla funzione contenitrice.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
cpp
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.