microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Go to Definition on includes can get stuck due to hover or documentHighlight requests that are stuck on IntelliSense updating (from document switching) #8885

Open sean-mcmanus opened 2 years ago

sean-mcmanus commented 2 years ago

Discussed in https://github.com/microsoft/vscode-cpptools/discussions/8881

Originally posted by **juxeii** February 18, 2022 We have a very large code base. One problem I have with Intellisense is that it reparses the active document although it has been parsed before. Here is an example of how I cannot work in a smooth fashion: I mark one include file A and click "Go to Definition". The file A opens in an instant which is fine. Now I go back to the original file from where I jumped from and browse to other include files. Now I want to browse to file A again(no changes were made). It can take many seconds now to open the file A again. I wonder why is that? Why is there no cache used which opens the file A again in an instant? On the console for C/C++ I can see "idle loop: reparsing the active document". Is there something I can do to improve the user experience here?
sean-mcmanus commented 2 years ago

@juxeii If you set C_Cpp.loggingLevel to "Debug" you should notice that the logging gets stuck on hover or documentHighlight requests, which are blocked by the IntelliSense update, and that is causing us to not get the Go to Def messages. We could potentially add code to avoid the IntelliSense update parse when the active document changes and/or stop sending hover and document highlight request messages on #include lines.

juxeii commented 2 years ago

@sean-mcmanus: Yes, I noticed there are not logger outputs while it tries to jump to the file in question.

Colengms commented 2 years ago

@sean-mcmanus A hang in documentHighlight could be https://github.com/microsoft/vscode-cpptools/issues/8717

sean-mcmanus commented 2 years ago

@Colengms No, I'm just referring to a normal/temporary delay of document highlight due to it being (temporarily) stuck waiting for the IntelliSense update.

simonboily commented 1 year ago

Has there been any progress on this issue? Any work arounds? This happens even on relatively small projects, every other f12 takes between 3-5 seconds to resolve, making VSCode a no-go tool for me.

sean-mcmanus commented 1 year ago

@simonboily Sorry, no progress yet. If you can avoid hovering or other mouse movement and do Go to Def via F12 that could help.

Kerdek commented 1 year ago

An extension can assume the responsibility of avoiding reparsing the document by storing the TextDocument reference in a map used to look up the parse result.

I recommend wrapping this behavior and calling it a day.