Vscode-cpptools: IntelliSense does not find symbols in current namespace

Created on 28 May 2019  Â·  3Comments  Â·  Source: microsoft/vscode-cpptools

Type: LanguageService

This appears to be related to issue #1029 but the example below is much simpler.

Describe the bug

  • OS and Version: Ubuntu 18.04.2 LTS
  • VS Code Version: 1.34.0
  • C/C++ Extension Version: 0.23.1
  • Other extensions you installed (and if the issue persists after disabling them): None
  • If there is a symbol, say 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

  1. Create a file tmp.h with the following lines:
#pragma once

namespace Foo
{
    class BarError {} ;
}
  1. Create a file named 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 */)
    }
}
  1. Place cursor after the 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:

Screenshot_2019-05-28_104949

  1. On the other hand, if one types Foo::, the completion does show up. This is shown in the figure below:

Screenshot_2019-05-28_105008

The completion does show up correctly in both cases when using a language server with NeoVim as shown in the figures below:

Screenshot_2019-05-28_105105

Screenshot_2019-05-28_105122

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.

Auto-complete Language Service Visual Studio bug

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.

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings