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

Code suggestions for multiple struct members don't appear in addition or subtraction expressions #2184

Closed
BrandonShockley opened this issue Jun 25, 2018 · 12 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Milestone

Comments

@BrandonShockley
Copy link

Type: LanguageService
----- Input information below -----

Describe the bug

  • OS and Version: Linux Mint 18.2
  • VS Code Version: 1.24.1
  • C/C++ Extension Version: 0.17.5
  • Other extensions you installed (and if the issue persists after disabling them): CMake, Makefile support, Python, Shader languages support. Issue persists after disabling.
  • When typing an addition or subtraction expression involving multiple struct members, Intellisense suggestions for the first struct member will appear, but suggestions for following struct members will only appear once you've fully typed them in. This only happens with addition and subtraction. Multiplication and division expressions work fine.

To Reproduce
Steps to reproduce the behavior:

  1. Given a struct Demo
struct Demo {
    int foo;
    char bar;
};
  1. Define a global Demo called test
    struct Demo test;

  2. Attempt to add two or more members of test in an expression

void doStuff() {
    int i = test.bar + test.foo;
} 
  1. Upon typing "test.", it is expected that a list containing foo and bar appear, but it does not for the second occurrence.

Expected behavior
It is expected that Intellisense suggestions will appear for all struct members in an expression.

Screenshots

bug

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jun 26, 2018

Thanks for reporting this. I'm able to repro it. It appears to not repro on Windows, which is unexpected (it turns out, my Linux machine was slower, making the repro easier).

UPDATE: Looks like edits were incorrectly getting queued async so the completion request would randomly occur before the required edits.

@bobbrow bobbrow added this to the 0.17.6 milestone Jun 26, 2018
@sean-mcmanus sean-mcmanus self-assigned this Jun 27, 2018
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Jun 27, 2018
@sean-mcmanus sean-mcmanus removed their assignment Jun 27, 2018
@sean-mcmanus
Copy link
Contributor

Should be fixed with 0.17.6.

@BrandonShockley
Copy link
Author

It's still happening on my system with version 0.17.6

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jul 5, 2018

@BrandonShockley I'm not able to repro any issue. Can you provide any suggestions on how to more easily repro the problem? We definitely fixed a bug here with edits getting delayed that caused completion to fail, but you could be hitting some other issue.

@BrandonShockley
Copy link
Author

I'm not sure what else I can specify. I tried the same thing I put in the bug description on a Windows machine and the bug happens on it too.

@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jul 6, 2018

Is the bug random when typing? What happens if you press Ctrl+Space with existing text? If you could run our extension from our typescript you could view the C/C++ Debug Protocol pane which shows logs about what messages are being sent, such as the logs below which show the correct completion. Does it repro with a new file? It's possible other code beforehand is causing a failure.

************************************************************************************************************************
{
    "jsonrpc": "2.0",
    "id": 178,
    "method": "textDocument/completion",
    "params": {
        "textDocument": {
            "uri": "file:///.../test3.cpp"
        },
        "position": {
            "line": 9,
            "character": 28
        }
    }
}
************************************************************************************************************************
Content-Length:632

{
    "jsonrpc": "2.0",
    "id": 178,
    "result": {
        "isIncomplete": false,
        "items": [
            {
                "label": "foo",
                "kind": 5,
                "detail": "int Demo::foo",
                "documentation": "File: test3.cpp",
                "sortText": "1foo",
                "insertText": "foo"
            },
            {
                "label": "bar",
                "kind": 5,
                "detail": "char Demo::bar",
                "documentation": "File: test3.cpp",
                "sortText": "1bar",
                "insertText": "bar"
            }
        ]
    }
}

@BrandonShockley
Copy link
Author

In experimenting, I think I discovered another bug. I had a test.c file open with int i = test.foo + test. as in the description (with some extra global variables defined), I closed out of the editor, deleted the test.c file, opened the editor (with its copy of test.c intact), and saved the file. The autocomplete then worked for the second test., but it also included some of the global variables that weren't part of the struct. This would stop once I deleted and retyped the second test. . This occurred on both Linux and Windows.

Regarding your questions, the bug isn't random. I've noticed it every time I've tried to add two struct members since I started using the extension in November. Ctrl + space shows "No suggestions". It occurs whether the file is new or not. I'll see about running it from typescript tomorrow afternoon.

@bobbrow
Copy link
Member

bobbrow commented Jul 6, 2018

I can repro if I use a C file, not C++. I think that was the missing detail.

@bobbrow bobbrow removed the fixed Check the Milestone for the release in which the fix is or will be available. label Jul 6, 2018
@bobbrow bobbrow modified the milestones: 0.17.6, 0.17.7 Jul 6, 2018
@bobbrow bobbrow reopened this Jul 6, 2018
@bobbrow
Copy link
Member

bobbrow commented Jul 6, 2018

It repros in Visual Studio too. I'll open a bug for them.

@bobbrow bobbrow added the parser label Jul 6, 2018
@sean-mcmanus sean-mcmanus removed this from the 0.17.7 milestone Jul 11, 2018
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jul 11, 2018

No ETA on when the VS team will be able to provide a fix for this...we'll update this when we have more info.

@sean-mcmanus
Copy link
Contributor

Bob filed a bug for this 5 months ago, but the Visual Studio C++ devs have been too busy to investigate. Please upvote the issue at https://developercommunity.visualstudio.com/content/problem/407956/cc-intellisense-no-member-list-appears-after-typin.html if you want them to fix this.

@sean-mcmanus
Copy link
Contributor

@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service Visual Studio Inherited from Visual Studio
Projects
None yet
Development

No branches or pull requests

4 participants