microsoft / vscode-cpptools

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

C_Cpp>Vc Format>Indent:Preprocessor Setting Not Applied in Nested Scenarios #11428

Open TwoBrushes opened 1 year ago

TwoBrushes commented 1 year ago

Environment

Bug Summary and Steps to Reproduce

1、when i set C_Cpp>Vc Format>Indent:Preprocessor to "none", but the Preprocessor(#define , #include...) always set to "leftmostcolumn"

2、When I use Doxygen to generate comments, the second line will automatically indent by one space. image

3、how can i define the auto indent format like this? image

Configuration and Logs

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

browntarik commented 1 year ago

Thank you for submitting your issue! To address your concerns in order:

1) Based on my testing, it looks like this feature is working as intended. In order to accurately test your setup, I would like you to test your settings on a simple .cpp file using this example:

class MyClass
{
    void Function()
    {
        #if DEBUG
        DebugPrint();
        #endif
    }
}

If you find the same issues, please let me know.

  1. This is intended behavior as doxygen comments are meant to be a formalized documentation style. If you would like to submit a feature request to be able to edit the indentation, please submit one here: https://github.com/microsoft/vscode-cpptools/issues/new?assignees=&labels=&projects=&template=3_feature-request.yml

  2. See response 1 to ensure your settings are working correctly or to confirm there is a bug that needs to be fixed.

TwoBrushes commented 1 year ago

Thank you for submitting your issue! To address your concerns in order:

  1. Based on my testing, it looks like this feature is working as intended. In order to accurately test your setup, I would like you to test your settings on a simple .cpp file using this example:
class MyClass
{
    void Function()
    {
        #if DEBUG
        DebugPrint();
        #endif
    }
}

If you find the same issues, please let me know.


class MyClass
{
    void Function()
    {
        #if DEBUG
        DebugPrint();
        #endif
    }
}
is working as intended, but

```c++
                                                #if TEST
class MyClass
{
   void Function()
   {
       #if DEBUG
       DebugPrint();
       #endif
   }
}
#endif

if TEST will "leftmostcolumn"

TwoBrushes commented 1 year ago

2. This is intended behavior as doxygen comments are meant to be a formalized documentation style. If you would like to submit a feature request to be able to edit the indentation, please submit one here: https://github.com/microsoft/vscode-cpptools/issues/new?assignees=&labels=&projects=&template=3_feature-request.yml

image

On the second line of the comment, @file has moved back one space, causing misalignment with @author below. I disabled the c/c++ extension and now it aligns correctly.

browntarik commented 1 year ago

Thank you for clarifying these scenarios, there is indeed a bug with preprocessor formatting in nested scenarios that our team will take a look at. I will further investigate the issue with doxygen formatting to verify if further action needs to be taken.

browntarik commented 1 year ago

@TwoBrushes the bug with preprocessor statements has been filed with our Visual Studio team (Internal Bug Number: 1885941). Please use this GitHub issue to keep track of when a fix for this issue has been addressed.

Thank you!