Skip to content

Go to Definition (F12) will list many redundant files #13660

Closed

Description

@gtianw

Environment

  • OS and Version: Windows_NT x64 10.0.19045
  • VS Code Version: 1.100.2 (system setup)
  • C/C++ Extension Version: 1.25.3
  • If using SSH remote, specify OS of remote machine: WSL2, Ubuntu20.04

Bug Summary and Steps to Reproduce

Bug Summary:
Go to Definition will list many redundant files.
These files are not included by CMakeLists.txt or compile_commands.json.
duplicates #11887, but it is no longer active.

Steps to reproduce:

  1. Download code from https://github.com/gtianw/Issue/tree/cpptools/13660
  2. F12 or Ctrl+LeftClick on target_prt.

Image

Expected behavior:
Only parse the file included by CMakeLists.txt or compile_commands.json, and directly jump to function definitions.

Activity

  1. gtianw commented on Jun 2, 2025

    @gtianw
    Author

    In a real project, there may be dozens of targets.

  2. sean-mcmanus commented on Jun 2, 2025

    @sean-mcmanus
    Contributor

    gtianw It looks like this is caused by the parent folder of main.cpp being the workspaceFolder root, so both CMake Tools and compile commands are recursively parsing the workspaceFolder for symbols. I believe that is "by design" but it's possible we could implement some design change. You could potentially use

        "C_Cpp.files.exclude": {
            "**/target2": true,
            "**/target3": true
        }

    Colen Garoutte-Carson (@Colengms) might have additional workaround suggestions.

  3. gtianw commented on Jun 3, 2025

    @gtianw
    Author

    I will switch between multiple targets according to the usage scenario, and very frequently, so C_Cpp.files.exclude is not suitable.

  4. sean-mcmanus commented on Jun 5, 2025

    @sean-mcmanus
    Contributor

    gtianw Are you able to not have the parent folder be used, i.e. by not having any source files at the root?

  5. sean-mcmanus commented on Jun 5, 2025

    @sean-mcmanus
    Contributor

    gtianw Otherwise, did you have some sort of design change in mind (that doesn't break existing user scenarios) to prevent files at the rule from causing recursive tag parsing of all the subfolders?

  6. gtianw commented on Jun 6, 2025

    @gtianw
    Author

    @gtianw Are you able to not have the parent folder be used, i.e. by not having any source files at the root?

    I tried, but the problem persists.

  7. gtianw commented on Jun 6, 2025

    @gtianw
    Author

    @gtianw Otherwise, did you have some sort of design change in mind (that doesn't break existing user scenarios) to prevent files at the rule from causing recursive tag parsing of all the subfolders?

    Maybe add a new option in c_cpp_properties.json, similar to limitSymbolToIncludeHeaders. When this option is enabled, only included files are parsed.
    It would be better if there was a global option that each Configuration name inherited by default.

  8. 9 remaining items

  9. sean-mcmanus commented on Jun 7, 2025

    @sean-mcmanus
    Contributor

    gtianw We decided to change the default behavior in the configurationProvider case to be what you expected and to not merge in the browse.path from the c_cpp_properties.json unless mergeConfigurations is set (#13678), i.e. when that change goes in, browse.path won't need to be explicitly set to [].

    We're not sure yet about the compileCommands case yet (i.e. that may still require the browse.path to be set to match the behavior with the configurationProvider), which is somewhat being tracked at #8274 (although in that case it just mentions merging forcedIncludes, and it's asking to change it to merge instead of to not merge, although I think any change we make to this would probably unify the behavior to what configurationsProviders does).

  10. gtianw commented on Jun 11, 2025

    @gtianw
    Author

    @gtianw Setting/adding

            "browse": {
                "path": []
            }
    

    in the configuration fixes it. I'm not sure if that is "by design" or not. I had includePath set to [] but that didn't work (as I had expected).

    Sean McManus (@sean-mcmanus) This is indeed a workaround, but it has significant limitations.
    Once I accidentally open redundant files, (i.e. target2/target.cpp when using target1 configuration), they will be added to the candidate.

  11. sean-mcmanus commented on Jun 11, 2025

    @sean-mcmanus
    Contributor

    gtianw If you open a file that is not normally tag parsed for symbols, we will tag parse it on open -- otherwise, document symbols won't work for the opened file -- but when you do a reload window after the file is closed, the symbols should be cleaned up after the workspace parsing phase is finished. We could potentially add a feature request to have a setting to not tag parse open files that are not normally parsed during workspace parsing.

  12. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Jun 13, 2025
  13. moved this from Pull Request to Done in cpptoolson Jun 13, 2025
  14. sean-mcmanus commented on Jun 19, 2025

    @sean-mcmanus
    Contributor

    gtianw Fixed for the configuration provider case with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.26.2 .

  15. sean-mcmanus commented on Jun 25, 2025

    @sean-mcmanus
    Contributor

    I'm closing this bug #8274 is still tracking handling the compile_commands.json case.

  16. gtianw commented on Jun 26, 2025

    @gtianw
    Author

    We could potentially add a feature request to have a setting to not tag parse open files that are not normally parsed during workspace parsing.

    Sean McManus (@sean-mcmanus) Which issue is used to track this new feature?

  17. sean-mcmanus commented on Jul 1, 2025

    @sean-mcmanus
    Contributor

    gtianw I don't think we've created one yet.

  18. locked and limited conversation to collaborators on Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Language ServiceenhancementImprovement to an existing featurefixedCheck the Milestone for the release in which the fix is or will be available.quick fix

Type

Projects

  • Status
    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions