Open birgersp opened 4 years ago
Yeah, TypeScript in VS Code has the auto-include adding capability. Our behavior matches C++ in VS which doesn't do this.
The feature will be helpful for me. But I think auto-completing for the contents that are not included may not be appropriate, since there would be a huge amount of partly or fully matched suggestions.
In my opinion, this feature should be added in "Quick Fix". I want it to show a list of choices for me and add the #include
statement automatically (just like TypeScript in VS Code). Then I can save my time and don't need to RTFM.
(For now it just suggest me change the includePath
)
@YalandHong If we were to implement this, it would probably only apply to a limited number of commonly used standard C++ types. But yeah, a Quick Fix for adding #include
s would be good too.
Yeah, TypeScript in VS Code has the auto-include adding capability.
I'd wager that this is a fairly common feature in IDEs.
The feature will be helpful for me. But I think auto-completing for the contents that are not included may not be appropriate, since there would be a huge amount of partly or fully matched suggestions.
Many suggestions is fine, as long as they're sorted by "relevance". It's the same as with any auto-completion feature.
Any news yet after 3 years?
Currently (please correct me if I'm wrong), it seems VSCode will not suggest definitions that are not yet included in the source file. This is despite the fact that the definitions reside in header files in
includePath
. Example below.For instance, say I wanted to create an instance of
std::map
in my source file. I have not yet added#include <map>
at the top of my source file.In some other C++ IDEs, a code suggestion will appear for
std::map
when I start typing it (see NetBeans example below). If I choose to accept the suggestion,#include <map>
is automatically added at the top of my source file.In VSCode, however, I'm not getting this suggestion unless I add
#include <map>
first.Suggestion: Enable IntelliSense to suggest definitions that are (not yet) included in the source file. Automatically add
#include (relevant header)
when accepting such a suggestion.