Skip to content

Non-recursive includes from workspaceRoot #475

@johnmellor

Description

@johnmellor

Currently ${workspaceRoot} is implicitly included in the includePath, and is recursively searched for header files.

This causes problems in projects which have files with the same name in different paths. For example:

base/string16.h
ui/string16.h
third_party/somelibrary/base/string16.h

Now when a file does #include "base/string16.h", VS Code finds all three of the string16.h headers, and the indexer gets confused about which one to use (it seems to default to ui/string16.h since that has the shortest path?). There are two problems here:

  1. It's presumably a bug that the indexer matches ui/string16.h when you #include "base/string16.h"?

  2. Finding both base/string16.h and third_party/somelibrary/base/string16.h is a more fundamental issue though. It may be possible to heuristically address this by preferring exact matches that don't require recursion, or preferring shorter paths. But for a robust solution there probably needs to be a way to disable the implicit recursive search of ${workspaceRoot} for includes. I tried adding an explicit includePath of "${workspaceRoot}/*" since the tooltip suggests specifying '*' to indicate non-recursive search, but that didn't seem to make any difference (presumably because includePath is in addition to the implicit workspace search, and/or because ${workspaceRoot} expansion wasn't yet supported?).

VS Code version: 1.10.0-insider
cpptools version: 0.10.0
OS: Ubuntu 14.04

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