microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Formatting does not work in the if statement in the λ expression to the right of the assignment statement … #12382

Closed Ebola-Chan-bot closed 5 months ago

Ebola-Chan-bot commented 5 months ago

Environment

版本: 1.90.0 (system setup) 提交: 89de5a8d4d6205e5b11647eb6a74844ca23d2573 日期: 2024-06-04T19:33:54.889Z Electron: 29.4.0 ElectronBuildId: 9593362 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.26236

Bug Summary and Steps to Reproduce

std::function<void()> A;
std::function<void()> *B;
B = &(A = [&B]()
     { if(B)B=nullptr; });

Formatting should add spaces to B=nullptr in the last line. But in fact, spaces are not added after formatting: image

Configuration and Logs

No c_cpp_properties.json

-------- Diagnostics - 2024/6/16 16:54:39
Version: 1.20.5
Current Configuration:
{
    "name": "Win32",
    "includePath": [
        "c:/Users/vhtmf/Documents/Arduino/Rp/**"
    ],
    "defines": [
        "_DEBUG",
        "UNICODE",
        "_UNICODE"
    ],
    "windowsSdkVersion": "10.0.22621.0",
    "compilerPath": "cl.exe",
    "cStandard": "c17",
    "cppStandard": "c++17",
    "intelliSenseMode": "windows-msvc-x64",
    "compilerPathInCppPropertiesJson": "cl.exe",
    "intelliSenseModeIsExplicit": false,
    "cStandardIsExplicit": false,
    "cppStandardIsExplicit": false,
    "mergeConfigurations": false,
    "compilerPathIsExplicit": false,
    "browse": {
        "path": [
            "c:/Users/vhtmf/Documents/Arduino/Rp/**",
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    }
}
cpptools version (native): 1.20.5.0
Translation Unit Mappings:
[ C:\Users\vhtmf\Documents\Arduino\Rp\main.cpp - source TU]:
Translation Unit Configurations:
[ C:\Users\vhtmf\Documents\Arduino\Rp\main.cpp ]:
    Process ID: 11480
    Memory Usage: 51 MB
    Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\bin\Hostx64\x64\cl.exe
    Includes:
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\include
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.40.33807\atlmfc\include
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt
        C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt
    Defines:
        _DEBUG
        UNICODE
        _UNICODE
    Standard Version: ms_c++17
    IntelliSense Mode: windows-msvc-x64
Total Memory Usage: 51 MB

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 5032

LSP: (received) cpptools/formatDocument: file:///c%3A/Users/vhtmf/Documents/Arduino/Rp/main.cpp (id: 61)
LSP: (invoked) cpptools/formatDocument: file:///c%3A/Users/vhtmf/Documents/Arduino/Rp/main.cpp (id: 61)
正在格式化文档: file:///c%3A/Users/vhtmf/Documents/Arduino/Rp/main.cpp
Formatting Engine: clangFormat
c:\Users\vhtmf\.vscode\extensions\ms-vscode.cpptools-1.20.5-win32-x64/bin/../LLVM/bin/clang-format.exe "-style={ BasedOnStyle: LLVM, UseTab: Always, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }" -fallback-style=LLVM -sort-includes=0 --Wno-error=unknown -assume-filename=C:\Users\vhtmf\Documents\Arduino\Rp\main.cpp
LSP: Sending response (id: 61)

Other Extensions

No response

Additional context

No response

sean-mcmanus commented 5 months ago

@Silver-Fang This is a bug with clang-format itself, as you can verify by running the command line:

c:\Users\vhtmf.vscode\extensions\ms-vscode.cpptools-1.20.5-win32-x64/bin/../LLVM/bin/clang-format.exe "-style={ BasedOnStyle: LLVM, UseTab: Always, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }" -fallback-style=LLVM -sort-includes=0 --Wno-error=unknown -assume-filename=C:\Users\vhtmf\Documents\Arduino\Rp\main.cpp C:\Users\vhtmf\Documents\Arduino\Rp\main.cpp

You should file a bug at https://github.com/llvm/llvm-project/issues if one doesn't exist yet.