microsoft / microsoft/vscode-cpptools
VcFormat setting C_Cpp.vcFormat.indent.lambdaBracesWhenParameter:true not respected when lambda has non trivial capture
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 6.2k
- Forks
- 1.7k
- Ø Merge
- 14 Std. 46 Min.
- Gemergte PRs (30 T.)
- 61
Beschreibung

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
- Ensure vcFormat is the cpp formatter
- 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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem bereitgestellten C++-Beispiel und der auf vcFormat konfigurierten Einstellung C_Cpp.formatting und vergleiche dann die Formatierung für einfache und nicht-triviale Lambda-Captures. Als erledigt gilt die Aufgabe, wenn Parameter-Lambdas mit nicht-trivialen Capture-Listen ihre Bodies relativ zur umgebenden Funktion eingerückt haben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100