microsoft / vscode-cpptools

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

Duplicates in outline view #4445

Closed higaski closed 4 years ago

higaski commented 4 years ago

Version 0.26.0 started to produce duplicates (or just now even triplicates) of every entry in the outline view.

E.g.

Although every C/C++ top bulletpoint can be collapsed thats still very confusing.

Version: 1.38.1 Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0 Date: 2019-09-16T10:22:16.623Z Electron: 4.2.11 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Linux x64 4.19.79-1-MANJARO

michelleangela commented 4 years ago

@higaski, can you provide an isolated sample file that reproduces the issue? Can you elaborate on what "top bulletpoint can be collapsed" is causing confusion?

higaski commented 4 years ago

Of course. Here is a screenshot of what my outline looks like with the attached "main.cpp" file. As you can see both functions (void foo and int main) are shown twice for whatever reason. When I first posted the issue 4h ago I somehow even ended up with three copies...?

duplicates_in_outline

main.cpp.zip

What I meant with the "top bulletpoints can be collapsed" is that the issue might be annoying, but as long as every top point can be collapsed its not that big of a deal.

michelleangela commented 4 years ago

@higaski, thanks for the sample file and screenshot. I still can't repro the issue though.

I tried with VSCode: Version: 1.39.1 Commit: 88f15d17dca836346e787762685a40bb5cce75a8 Date: 2019-10-10T23:30:33.955Z Electron: 4.2.10 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Linux x64 4.15.0-46-generic

Do you have any other extensions for C/C++ besides vscode-cpptools enabled?

higaski commented 4 years ago

Disabling all my other extensions didn't change anything. What did though was creating a new workspace. So apparently the problem is caused by any of my workspace settings... now the question is which one. :)

michelleangela commented 4 years ago

Please let us know if you figure out which workspace settings so we can try to fix the issue.

higaski commented 4 years ago

The problem doesn't seem to be the workspace settings but rather something with the folders added to it.

Any chance that this could have something to do with either a CMakeLists.txt or c_cpp_properties.json file?

When I remove all the project folders from my workspace and just add the example above everything works fine. Once I add a complex project (like 100k lines of code, multiple dependencies and complicated cross-platform cmake stuff) things start to break. Interestingly it then breaks for every project in the current workspace...

michelleangela commented 4 years ago

It sounds like there may be an issue with the IntelliSense database. Can you try running the command C/C++: Reset IntelliSense Database for the workspace that has complex projects and see if that does anything?

Can you also run C/C++: Log Diagnostics and share the logs?

higaski commented 4 years ago

Ok, describing the behavior of that bug is becoming increasingly difficult, even if I'd have to do it in my first language, so please bear with me. :)

So I currently have two projects in my workspace. One is a pretty simple Qt application with rather oldschool style C++ and the other one a library for an embedded system using pretty much the latest features of GCC/Clang and also including the GTest framework. Neither of those projects contain a c_cpp_properties.json file, but both are built with cmake.

So before doing anything else I've reset the IntelliSense Database for both projects and used Reload Window... because... just in case?

Now as long as I only open code from my Qt project everything is fine. Variables, functions, declarations, everything shows correctly without any duplication.

Once I open any file from the other project things get funky. The outline suddenly fills with a trillion things from libstdc++, GTest and Qt. All those things are shown under a top C/C++ bulletpoint wheres the stuff from the actual opened file is at the bottom of the outline under a second C/C++ bulletpoint.

After that I added another small project to the workspace and opened some of its files. Again the outline was absolutely cluttered with stuff which definitely does not belong there (e.g. libstdc++ declarations, definitions from other projects, ...)

Here is a log file for the project I added last: c_cpp_log.txt

sean-mcmanus commented 4 years ago

We got a repro on Linux -- seems to repro with any multi-root folder.

Alxe commented 4 years ago

What's the status of this issue? I'm curious if this is just visual or actually affects actual usage other than excess information.

I noticed that a new outline is created per folder in a workspace, in which each folder has files that load the extension, thus prompting the outline duplication. This may be related to some global usage of state?

I submit a screenshot showing three outlines, with three toy folders in a workspace. As you can see, the class declarations are different, but the outline only shows the current file. While filming the screenshot, I noticed that once the outline displayed both example1 and example3 for the project1/example.cpp file, but couldn't reproduce it. I suspect it's related to adding a new workspace folder while an outline is already loaded.

image

For additional information, I'm running Visual Studio Code 1.41.1 on Linux x64 with the 0.26.3-insiders3 version of the extension.

sean-mcmanus commented 4 years ago

@Alxe The status is that we have an internal vsix that implements a new multi-root that is expected to fix this (verification to be done soon), but we're still testing and bug fixing, so it might be a couple weeks or so till it will be available to try in an Insiders release.

sean-mcmanus commented 4 years ago

Our latest Insiders release has a new multi-root implementation (which fixes this bug): https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders. Please let us know if you find any multi-root-related bugs or regressions so we can prioritize fixing those for 0.27.0.