microsoft / vscode-cpptools

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

Member function requires-clause without parenthesis prevents code folding #9660

Open harichards opened 2 years ago

harichards commented 2 years ago

Environment

When adding a requires-clause to a class member function, if the constraints are not wrapped in parenthesis then code folding does not work on the function body. The arrow to fold is missing from the editor. Using keyboard shortcuts to fold code sections also does not work.

The workspace is a single, small project with a few header files.

Bug Summary and Steps to Reproduce

Bug Summary: Member function requires-clause without parenthesis prevents code folding.

Steps to reproduce:

  1. Create a C++ file in the editor.
  2. Write a template class with a member function.
  3. Add a requires-clause to the member function without parenthesis.
  4. Code folding arrow is missing from function body.

Expected behavior

A code folding arrow should appear next to the line number of the opening brace of the function body, allowing me to collapse this code section.

Code sample and Logs

Code sample:

#include <concepts>

template <typename View>
class my_view
{
    View m_base;

public:
    View base() const
        requires std::copy_constructible<View>
    {
        return m_base;
    }
};

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Linux",
            "intelliSenseMode": "linux-gcc-x64",
            "includePath": [
                "${workspaceFolder}/include"
            ],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "c++20"
        }
    ],
    "version": 4
}

Screenshots

No folding arrow: image

Folding arrow: image image

Additional context

No response

sean-mcmanus commented 2 years ago

I've filed a bug against our shared VS implementation at https://developercommunity.visualstudio.com/t/C-IntelliSense-member-function-require/10107513 .