Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intellisense fails to distinguish same name files in different directories #12296

Open
Saitama10000 opened this issue May 10, 2024 · 2 comments
Assignees
Labels
by design Language Service more info needed The issue report is not actionable in its current state

Comments

@Saitama10000
Copy link

Saitama10000 commented May 10, 2024

Environment

  • OS and Version: Windows 11 and Ubuntu 22.04
  • VS Code Version: 1.89.1
  • C/C++ Extension Version: 1.20.5
  • If using SSH remote, specify OS of remote machine: -

Bug Summary and Steps to Reproduce

Bug Summary:
Intellisense fails to distinguish same name files in different directories

Steps to reproduce:

  1. clone this: link to github repo with bug
  2. create a build directory in root
  3. run cd build && cmake .. && cmake --build . (build the repo to check that there are no errors from the compiler)
  4. set extension c++ standard to c++20
  5. open ./dir/dir0/src/main_0.cpp and hover over test_0_t. Intellisense identifies it.
  6. open ./dir/dir1/src/main_1.cpp and hover over test_1_t. Intellisense doesn't identify it.

Expected behavior:
6. open ./dir/dir1/src/main_1.cpp and hover over test_1_t. Intellisense should identify it like it did for main_0.cpp

Configuration and Logs

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc"
        }
    ],
    "version": 4
}

Other Extensions

No response

Additional context

No response

@browntarik
Copy link
Contributor

browntarik commented May 13, 2024

Thanks for reporting this issue. It looks like what you are experiencing is by-design behavior. Due to the limitations of what we can differentiate header files by, you can't use the filename as the relative path in this case. It would be more correct to provide the folder that each file resides in as well. See the example below:

image

Does this help you with your issue?

@browntarik browntarik self-assigned this May 13, 2024
@browntarik browntarik added the more info needed The issue report is not actionable in its current state label May 13, 2024
@sean-mcmanus
Copy link
Collaborator

@Saitama10000 To add more info, I believe it's caused by usage of "${workspaceFolder}/**" in which the include order is non-deterministic. You may be able to workaround the issue by adding a path to your include path before that to cause that path to get precedence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
by design Language Service more info needed The issue report is not actionable in its current state
Projects
None yet
Development

No branches or pull requests

3 participants