Type: LanguageService
This appears to be related to issue #1029 but the example below is much simpler.
Describe the bug
BarError, inside a namespace, say Foo, in a header and one is editing a .cpp file, IntelliSense is unable to find this symbol BarError while cursor is inside namespace Foo { } block.To Reproduce
tmp.h with the following lines:#pragma once
namespace Foo
{
class BarError {} ;
}
tmp.cpp in the same folder with the following lines:#include "tmp.h"
namespace Foo
{
void vscode_bug()
try {
} catch(const /* place cursor after const<space> and type Bar */)
}
}
const on the line with catch-statement and type Bar. One would expect IntelliSense to provide BarError as a completion option. But this is not the case. This is what we get:
Foo::, the completion does show up. This is shown in the figure below:
The completion does show up correctly in both cases when using a language server with NeoVim as shown in the figures below:


Expected behavior
As described above, symbol BarError should appear in completion list inside namespace Foo {} block but does not appear unless explicitly qualified using Foo::.
Screenshots
Screenshots included inline in the description above.
Additional context
This bug was reproduced with default configuration of VS Code and C++ tools. No customization was performed.
I've filed a bug on Visual Studio 2019 (the source of the bug) at https://developercommunity.visualstudio.com/content/problem/588356/c-intellisense-autocomplete-fails-to-locate-namesp.html . If you have a Microsoft account you can login to upvote that issue.
One potential workaround is to surround the method with {} instead having the try/catch around the body.
I've filed a bug on Visual Studio 2019 (the source of the bug) at https://developercommunity.visualstudio.com/content/problem/588356/c-intellisense-autocomplete-fails-to-locate-namesp.html .
Thanks.
One potential workaround is to surround the method with
{}instead having the try/catch around the body.
Another workaround that does not require one to change the C++ code is to use vscode-clangd extension. It produces the correct expected completions.
I am observing the same bug in vsc1.41.1+ms-vscode.csharp.
Most helpful comment
I've filed a bug on Visual Studio 2019 (the source of the bug) at https://developercommunity.visualstudio.com/content/problem/588356/c-intellisense-autocomplete-fails-to-locate-namesp.html . If you have a Microsoft account you can login to upvote that issue.
One potential workaround is to surround the method with
{}instead having the try/catch around the body.