30

I've started to get errors Unable to open 'header.h': File not found when I try to jump to var/func definition via [Ctrl+Click] after I've deleted/renamed several files.

Is it possible to force reindex source code?

rinatdobr
  • 543
  • 1
  • 6
  • 14
  • 4
    I didn't find a key combination to directly make VSCode reindex, but you can [reload VSCode](https://stackoverflow.com/questions/42002852/how-to-restart-vscode-after-editing-extensions-config) instead (it pretty quick action). Reloading it should make it reindex. – SubMachine Dec 29 '19 at 13:36
  • Did you use a `c_cpp_properties.json` file in your `.vscode` folder? – ai2ys Jan 16 '22 at 11:36
  • 2
    By the way, to reload, you want to open the command panel, or `Cmd + Shift + P` (for mac, for windows, use `ctrl`) then type "Reload Window" and find "Developer: Reload Window". I believe the default shortcut is `Cmd + r` –  Jun 12 '22 at 21:33

1 Answers1

9

This question is a few years old now, but this is an issue I've seen a lot, and can usually be fixed with one of the following 5 options:

Reload Session

You can reload the current session, with the workbench.action.reloadWindow command:

Open the Command Palette with Ctrl + Shift + P Then type Reload Window


Filter Files being Indexed

For C/C++ projects specificially, sometimes the intellisense indexing can be really slow, and feel like it's not working. One solution for this is to limit what it indexes with something like limitSymbolsToIncludedHeaders, or reduce the amount of parsed files in c_cpp_properties.json

"browse": {
  "path": [
    "/usr/include/",
    "/usr/local/include/",
    "${workspaceRoot}/../include",
    "${workspaceRoot}/dir2",
    "${workspaceRoot}/dir3/src/c++"
    ...
  ]
}

Set File Associations

Sometimes the file associations are incorrect, so files are not indexed as expected. This can be fixed by adding something similar to this into your VS Code settings (settings.json):

"intelephense.files.associations": ["*.php", "*.phtml", "*.inc", "*.module", "*.install", "*.theme", ".engine", ".profile", ".info", ".test"]

Rebuild System Index

For Windows users, VS Code uses the system search index, so rebuilding that may help.


Ensure Intellisense Enabled

Finally, it may seem obvious, but just confirm that Intellisense is actually enabled, with editor.tabCompletion in your settings.json. And if you're searching with results not displaying, ensure there aren't any filters preventing results.

Alicia Sykes
  • 5,997
  • 7
  • 36
  • 64
  • https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference for the whole description of the "browse" fild – Cutton Eye Feb 02 '23 at 17:50
  • Ctrl+Shift+P + ">Developer: Reload Window" is now just Ctrl+R like in a browser, according to the popup, but Ctrl+R seems to be mapped to something else globally, so the shortcut doesn't seem to work. Manually selecting the option reindexes everything though. Thanks. – Luke Hutchison Feb 21 '23 at 18:40