Skip to content

VSCode C++ outline view in sources (*.cpp) does not group methods by class names (in hierarchy) #8100

@raymond-wh-leung

Description

@raymond-wh-leung

Bug type: Language Service

Describe the bug
I came across the same issue reported from this thread for VSCode C++ outline view.
(microsoft/vscode#107161).

In short, the C++ outline view does not show class methods in hierarchy if the editor is in the source (*.cpp), it will show something like below.

o MyClassName::Method1()
o MyClassName::Method2()
o ...
o MyClassName::MethodN()

(every method is appended with the class name MyClassName::)

It happens very often that our sources have very long class name, this makes the outline view almost unusable because what you’ll see there is a list of “LooooongClassName::Method”, and those method name will get cut off (unless you make the outline view very wide). (there is no horizontal scrollbar there.)

And I wonder if we can make the outline view group by class name even in source *.cpp?

  • Trial
    o MyClass
    - Method1()
    - Method2()
    - …

This is one major thing that I missed a lot when switching over to VSCode from Source Insight 3.5 (Source Insight 3.5 grouped the methods by class name and that makes the outline very handy.)

VSCode (with C++ extension) is great and I like it a lot. If we can address the above, it will make the experience much better!!

  • OS and Version:
    Windows 10

  • VS Code Version:
    Version: 1.59.1

  • C/C++ Extension Version:
    Latest (1.6.0)

  • Other extensions you installed (and if the issue persists after disabling them):
    No other extensions installed that would affect that C++ outline view.

  • If using SSH remote, specify OS of remote machine:

  • 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).
    C++ outline view when editor is in source (*.cpp) shows all methods in the from of "MyClassName::Method". Very often there are long class name, and it will show "LooooongClassName::Method" in the outline view, and the method name will get cut off unless you make the outline view very wide. (that makes the outline view not usable in that case, there is no horizontal scrollbar there.) The experience will be much better if the methods shown in the outline view is grouped by class name (in hierarchy). (Some other editors like source insight 3.5 does that and it makes the outline view very handy.)

Steps to reproduce

  1. Create a new C++ class (with a header *.h and source *.cpp) with a long class name, like "MyLoooooooooongClassName".
  2. Add some methods there, like Method1(), Method2(), Method3().
  3. Open the source with *.cpp
  4. Open outline view "View -> Explorer, then Outline"
  5. You will see that all methods in the outline view are appened with "MyLoooooooongClassName::"
  6. What you see in the outline view is just "MyLooooooooongClass::" (unless you make the outline view very wide.)
  7. The situation will be worse if the class has lots of methods (which is very often the case.)

Expected behavior
Expect the outline view to group the methods by class name: (as the class name on every method is redundant.)

  • Trial
    o MyClass
    - Method1()
    - Method2()
    - …

Code sample and logs

  • Code sample

  • Configurations in c_cpp_properties.json

  • Logs from running C/C++: Log Diagnostics from the VS Code command palette

  • Logs from the language server logging

Screenshots
microsoft/vscode#107161

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions