vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Member function requires-clause without parenthesis prevents code folding

Open harichards opened this issue 2 years ago • 1 comments

Environment

  • OS and Version: Windows 11 Home 21H2
  • VS Code Version: 1.69.2 (user setup)
  • C/C++ Extension Version: 1.11.4
  • Other extensions you installed (and if the issue persists after disabling them): None
  • If using SSH remote, specify OS of remote machine: Ubuntu 22.04 5.10.102.1-microsoft-standard-WSL2 (using WSL remote)
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).

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

harichards avatar Jul 29 '22 13:07 harichards

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

sean-mcmanus avatar Jul 29 '22 17:07 sean-mcmanus