Vscode-cpptools: "exclude path" in c_cpp_properties.json

Created on 24 Nov 2017  Â·  15Comments  Â·  Source: microsoft/vscode-cpptools

  • Ubuntu 17.10
  • vscode 1.18.1
  • C/C++ 0.14.2

I miss the possibility to exclude directories from a configuration. For example:

  • Directories containing build artifacts should not appear when quick opening a file (CTRL-P) or searching for/inside files.
  • If multiple configurations share large parts of the source code tree, only symbols relevant for the currently selected configuration should be navigated.

I have tried to specify specific directories for each configuration but all symbols appear, active configuration disregarded. Is the path definition for intellisense recursive or not? Seems kind of both to me.

Language Service question

Most helpful comment

It did work for me in the end. I added the folders I didn't want searched into settings.json under "files.exclude" and "search.exclude" as in the example above (I used full path).

Then I closed VSCode and deleted the database files from .vscode, and reopened. Without deleting the DB it kept the references to the unwanted files.

All 15 comments

You might need to provide us a little more detail, but this is the extension's general strategy:

  • The paths you want to index for code browsing are specified in the "browse.path" setting (per-config in c_cpp_properties.json).
  • These paths are recursive by default, so if you include ${workspaceRoot} we will index everything in that folder and its subfolders.
  • If you want to turn off recursive for a folder, you append a /* to the path. ${workspaceRoot}/* instructs the indexing service to only index the files in ${workspaceRoot} and skips all subfolders.
  • VS Code also has global/workspace exclusion settings that we honor: files.exclude and search.exclude. If you specify ${workspaceRoot} in your "browse.path", but add ${workspaceRoot}/build to files.exclude, we will recursively index ${workspaceRoot} and skip the ${workspaceRoot}/build folder.

OK. I understand, but given a project with many directories it could be a feature to exclude certain paths and else rely on recursiveness.

Is the includePath for intellisense also recursive? One project I'm on can be configured using a pre-processor macro to build different targets. The pre-processor define selects which files to include and which parts of the code to compile. In c_cpp_properties.json I've specified a configuration for each target holding respective target's define and unique include paths. However, even though one configuration (target) is active I can see the other target's symbols when browsing global symbols.

includePath is not recursive.

For your second issue, do you happen to specify a databaseFilename for each of your configs, or do you leave this field empty? If you leave it empty (the default), we end up sharing the DB across configs and old symbols will remain in the DB until the indexing completes on the config you just switched to and we run the cleanup step.

If you expect to change configs often, I recommend you set a unique name for the database for each config. Perhaps we should change the default behavior to stop sharing the DB across configs and generate a unique filename for you. The theory was that users would likely have most of the same navigation preferences across configs, but this doesn't appear to be the case for your project.

OK. Thanks. My databaseFilename is empty. Sounds like a good option to let the user be able to select the scope of symbol search. The most intuitive would be to keep it per configuration by default.

Regarding browsePath:
Say there is a build folder inside the workspace at "workspace/app/build". What happens if I add both "{workspaceRoot}" and "{workspaceRoot}/app/build/*" in my configuration. Will the build folder be excluded? Tried testing adding them in different order but the contents of the build folder still appears when searching for files.

The build folder would be included in that case because ${workspaceRoot} (recursive) was added to the list. You would need to list the folders under your build folder in files.exclude if you wanted them removed.

also looking for the ability to exclude paths from the search.

@Spongman There is a search.exclude setting. We look at the for filtering for symbol searching results.

Was this feature implemented? cpptools cannot exclude path for symbol searching result.

For example, I want to exclude path ${workspaceFolder}/.xxxx. The following settings does not work. go to def still find symbols in ${workspaceFolder}/.xxxx

c_cpp_properties.json

"includePath": [
    "${workspaceFolder}/**",
]

settings.json

"files.exclude": {
      "**/.xxxx": true
},
"search.exclude": {
    "**/.xxxx": true
 },

It did work for me in the end. I added the folders I didn't want searched into settings.json under "files.exclude" and "search.exclude" as in the example above (I used full path).

Then I closed VSCode and deleted the database files from .vscode, and reopened. Without deleting the DB it kept the references to the unwanted files.

It did work for me in the end. I added the folders I didn't want searched into settings.json under "files.exclude" and "search.exclude" as in the example above (I used full path).

Then I closed VSCode and deleted the database files from .vscode, and reopened. Without deleting the DB it kept the references to the unwanted files.

@sosaucily How do I delete DB. Where is the location of the DB? Is it same as C/C++: Reset Intellisense database?

@ivorynoise Yes, you should use C/C++: Reset IntelliSense Database to delete the database. It's located at an OS's-specific default location, which can be changed via the C_Cpp.default.browse.databaseFilename setting, e.g. to "${workspaceFolder}/vc.db". The Rescan Workspace command may also fix database issues.

Thanks. Do you know the OS default location for db file? I just want to
cross check if everything is cleaned up.

On Thu, 7 May, 2020, 12:14 AM Sean McManus, notifications@github.com
wrote:

@ivorynoise https://github.com/ivorynoise Yes, you should use C/C++:
Reset IntelliSense Database to delete the database. It's located at an
OS's-specific default location, which can be changed via the
C_Cpp.default.browse.databaseFilename setting, e.g. to
"${workspaceFolder}/vc.db".

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/microsoft/vscode-cpptools/issues/1284#issuecomment-624822505,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACVSPGQLQXIJJIJNWPON5J3RQGVZDANCNFSM4EFIWQNA
.

@ivorynoise Actually, I think they may have changed it to be named workspaceStorage, i.e. some path like Code\User\workspaceStorage\0d73b37eaf9bc4ce5ec6ccc0cb97276c\ms-vscode.cpptools . Or you could search for .BROWSE.VC.DB files.

This issue has been closed automatically because it's labeled as a 'question' and has not had recent activity.

Was this page helpful?
0 / 5 - 0 ratings