100

If you make a code change while VsCode is debugging, the intellisense sometimes appears to malfunction with false compile errors. Fastest way to reset or correct it?

2
  • 3
    Not sure if it applies here, but deleting the .vs folder next to your project (while VS is closed) solves a wide range of ills. Commented Dec 7, 2017 at 18:20
  • Sidenote: In C#, Omnisharp walks the sln file. If you add a new project, and forget to add it to the solution, this can make intelligence fail on packages specific to that project. Add the project to the solution, and run command "Omnisharp: Restart Omnisharp" from command palette. Commented Jul 2, 2022 at 10:42

11 Answers 11

188

Restart the TypeScript language service

In VS Code, and in a TypeScript source file (this won't work in a css or json file),

  1. Open the Command Palette (view menu → command palette)
  2. Enter TypeScript: Restart TS server. (type "restart" and it should autosuggest)
5
  • 31
    The command only shows up when you have a TypeScript file open! You won't find it while editing a .css file for example.
    – nitzel
    Commented Jun 12, 2019 at 14:44
  • 2
    And if you have a .cs file open, you get the option to Restart OmniSharp, which clears up c# issues, such as incorrect error-flagging for files, Commented Nov 20, 2019 at 19:11
  • @DrumM -- to restart typescript in vscode, you have to use the command palette in a typescript file (eg, won't work in a css or json file) -- perhaps consider adding the line "typescript.tsdk": "node_modules/typescript/lib/" to your .vscode/settings.json -- also be sure to install typescript locally in the project via npm install typescript -- then give vs code a restart -- and of course as a workaround, restarting vscode entirely does work Commented Dec 19, 2019 at 9:59
  • You can go into File > Preferences > Keyboard Shortcuts and look up Typescript: Restart TS Server and give it a key binding (I gave mine ctrl + PauseBreak)
    – Daniel
    Commented Dec 28, 2021 at 1:12
  • If you're using the Vue extension, it will be: Volar: Restart Vue server
    – OCarneiro
    Commented Sep 10, 2023 at 15:38
39

You may Ctrl+Shift+P or F1, then write "reset.." in command pallete, and choose in popup list "C/C++ Reset IntelliSense database".enter image description here

1
  • Man, this even doesn't work for me. It seems there is a big bug. I'm running the latest version. Whatever I do, I always get: "No definition found for ..."
    – jaques-sam
    Commented Dec 18, 2019 at 10:07
13

In VSCode, Ctrl + Shift + P and click C/C++ Rescan Workspace works for me.

1
  • 1
    Maybe a C/C++ Reset IntelliSense database is needed before C/C++ Rescan Workspace as in @Valex answer. And a rebuild may help also. Commented Apr 3, 2020 at 1:33
12

For C# use this:

cmd+shift+P or ctrl+shift+P brings up command bar, then OmniSharp: restart OmniSharp. Type restart and it will suggest that.

11

For Angular / TypeScript, resetting the extension host worked reliably.

Ctrl + Shift P --> Restart Extension Host

--or--

Ctrl P --> then type ">" --> Restart Extension Host

2
  • 1
    worked also for C# Commented Sep 15, 2022 at 9:27
  • 1
    Also working for Python/Pylance in Jupyter notebooks.
    – Kriggs
    Commented Aug 14, 2023 at 10:02
7

Restart VsCode.

If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue.

3
  • 2
    this is still an issue... i've been restarting vscode for typescript projects like 10 times a day for the last three years... vscode will wrongly report definition errors which simply disappear by simply restarting vscode.. somehow the language service goes haywire on the regular *shrugs* Commented Dec 13, 2018 at 21:44
  • 13
    hey i found something -- View menu -> Command palette, type restart, then click TypeScript: Restart TS server. Commented Dec 13, 2018 at 21:48
  • 1
    @ChaseMoskal This is much more efficient!
    – Jeff
    Commented Feb 13, 2019 at 15:33
3

I had the problem where the following did not work:

  • Quitting VSCode
  • Disabling the C/C++ extension
  • C/C++ Reset IntelliSense database
  • C/C++ Rescan Workspace

I discovered that I had a bunch of processes running called cpptools and cpptools-srv. After killing all of them and resetting VSCode, everything started working again.

The command I use to kill them is:

pkill cpptools

Under most circumstances, I do not need to quit VSC after using the pkill command above.

0
1

Restart the Dart Analysis Server

Well since this question is a bit generic and seeing people responding with ways to solve for various programming languages, I'll post that of Dart.

  • Open the Command Palette (view menu → command palette)
  • Type: Dart: Restart Analysis Server and press Enter

Just like closing and reopening vscode

1

For .NET within new version of VS code omni sharp replaced with language server. You can restart with that command. Hope its help.

.NET: Restart Language Server

0

I'm using an older version of VS Code (1.48.1). This answer solved the problem for me of a file not generating C/C++ IntelliSense information. If resetting the IntelliSense is not enough (Ctrl+Shift+P → C/C++: Reset IntelliSense database; it wasn't for me), try this:

Make sure there are no red squiggles (parsing errors) in the file, especially on #include directives. The best way to resolve include problems is to declare more include directories in the workspace. (I saw a lot of answers on how to do it system/user-wide, but only incomplete answers on how to do it per workspace.) Do this by generating a c_cpp_properties.json file in the workspace directory (mine didn't seem to have one already): Ctrl+Shift+P → C/C++: Edit Configurations (JSON). Add paths to includePath, until all include errors go away in the problematic file and in all files that it includes. Use the variable, ${workspaceFolder} to refer to the root directory of the workspace. By the way, mine defaulted to only having ${workspaceFolder}/** in includePath, which should recursively search your entire workspace folder for include files. It did not work for me, at least on one particular file. I had to explicitly add more directories under ${workspaceFolder}, in order for VS Code to find some includes. I didn't have any issue with standard library includes. So, this answer does not address those.

You may need to do another reset of the IntelliSense database and restart VS Code before it starts showing all IntelliSense information properly. I also found that it seemed to help to open the include files that it's looking for to help it find the files. I'm hoping this keeps working for me. So far so good.

0

What worked for me is that, I installed an earlier version of Intellisense.

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Feb 4 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.