Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structure members are not displayed in suggestions when used in an arithmetic expression after a + or a -. #1905

Closed
surify opened this issue May 1, 2018 · 13 comments

Comments

@surify
Copy link

surify commented May 1, 2018

operating system: xubuntu 16.04.1
vscode version: 1.22.2(I am not using insiders build)
C/C++ extension version: 0.16.1
The only extension I have installed currently is this(C/C++).
Example Code Sample:

#include <stdio.h>

typedef struct
{
    char name[30];
    char gender;
    int rollno;
    int marks;
}student;

int main(void)
{
    student s;
    int i, j, k, l;
    i = 5 - s.rollno;
    j = s.marks;
    k = 5 * s.rollno;
    l = 5 + 3 * s.rollno;
    return 0;
}

In the above example after declaring s to be of type student, in the assignment of i after I type "5 - s.", no suggestions are shown. but in the next line on assignment of j, as soon as i type " s. " all members of s are shown. same is the case with assignment to k. But in the assignment to l, as there is a + in the expression before using the structure member no suggestions are shown after typing " s. "

The structure member suggestion is working perfectly fine everywhere else like direct assignment, function parameters, etc except when used in an arithmetic expression after(not just immediately after) a + or a -.

After hitting " s. " in an expression after a + or a - no suggestions are shown automatically. If I hit ctrl+space then the members of the structure s are shown along with all variables and keywords in the code.

If the structure is defined in another header file and #included in this file, the members are not shown after I type " s. " and hit ctrl+enter. To make it clear this is only occurring only if a + or a - is in the arithmetic expression before the use of the structure member.

I have even tried completely uninstalling vscode from the computer.

  1. sudo apt purge code
  2. Deleted .vscode directory from my home directory.
  3. Deleted Code directory from ./config.

After the reinstall, it looked like fresh install. I installed only C/C++ extension. But the issue is the same.

linux related settings from c_cpp_properties.json
{
"name": "Linux",
"includePath": [
"${workspaceFolder}",
"/usr/include/c++/5",
"/usr/include/x86_64-linux-gnu/c++/5",
"/usr/include/c++/5/backward",
"/usr/lib/llvm-5.0/lib/clang/5.0.0/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu",
"/usr/include"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"${workspaceFolder}",
"/usr/include/c++/5",
"/usr/include/x86_64-linux-gnu/c++/5",
"/usr/include/c++/5/backward",
"/usr/lib/llvm-5.0/lib/clang/5.0.0/include",
"/usr/local/include",
"/usr/include/x86_64-linux-gnu",
"/usr/include"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17"
}

Please help me.

@bobbrow
Copy link
Member

bobbrow commented May 1, 2018

Sounds like a bug. I didn't see the problem you describe when I tried it, but we can look into it further. Just checking... did you change the "editor.quickSuggestions" setting at all or are you using VS Code's default? That will determine which behavior I should look for.

@bobbrow bobbrow added Language Service more info needed The issue report is not actionable in its current state labels May 1, 2018
@surify
Copy link
Author

surify commented May 1, 2018

I am using the VS code's default. I even checked by installing vscode on xubuntu 16.04.1 live. I installed only the C/C++ extension. Same issue exists. Its strange that it is happening with only + and -.

@bobbrow bobbrow added bug and removed more info needed The issue report is not actionable in its current state labels May 1, 2018
@surify
Copy link
Author

surify commented May 1, 2018

I just tested on Linux Mint 18.2 xfce live(It is based on ubuntu 16.04.1) and the issue is not there. Everything is working great here.

@bobbrow
Copy link
Member

bobbrow commented May 1, 2018

Perhaps the extension is not running at all on your other machine? Can you set "C_Cpp.loggingLevel": "6" and see if anything shows up in the C/C++ channel of the Output Window (or if the C/C++ channel even exists)?

@surify
Copy link
Author

surify commented May 1, 2018

Pardon me but I don't know what a C/C++ channel is. But when I set the "C_Cpp.loggingLevel" to "6",
an error showed up in its problem window saying that value not accepted. If that helps.

@surify
Copy link
Author

surify commented May 1, 2018

I have a small doubt sir.
If the extension is not at all running on my machine, then why does it work at all. Why only fail if there is a + or - before it in the arithmetic expression. It is working fine everywhere else like function parameters and direct assignments.

@bobbrow
Copy link
Member

bobbrow commented May 1, 2018

You can ignore the error about "6". It's a hidden value that we only use for debugging issues. You should delete it when we're done because it logs a lot more information that you normally need.

This is what I mean by the "channel"
image

VS Code provides auto complete in some cases based on the text in your file, so I'm trying to see if that's what you're getting or not.

@surify
Copy link
Author

surify commented May 1, 2018

Yeah, I have a C/C++ channel

@surify
Copy link
Author

surify commented May 1, 2018

If it helps, the below message appeared in c/c++ channel after I set C_Cpp.loggingLevel to its default.

$/setTraceNotification
workspace/didChangeConfiguration
IntelliSense Engine = Default.
The extension will use the Tag Parser for IntelliSense when #includes don't resolve.
Autocomplete is enabled.
Error squiggles are enabled.

@sean-mcmanus
Copy link
Contributor

This sounds the same as #2184 . We had a bug were edits randomly weren't being processed before the completion request. Let us know if this still repros after we ship 0.17.6.

@surify
Copy link
Author

surify commented Jun 28, 2018

sure

@sean-mcmanus
Copy link
Contributor

Should be fixed with 0.17.6.

@sean-mcmanus
Copy link
Contributor

The issue with C files was fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/0.30.0-insiders4 .

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants