microsoft / microsoft/vscode-cpptools

Problem with structure field hints

Open
#14,590 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug verified Visual Studio
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Environment
  • OS and Version: Windows 10 LTSC 2018
  • VS Code Version: 1.129.1
  • C/C++ Extension Version: 1.32.2
Bug Summary and Steps to Reproduce
  1. Create a main.c file with the following contents::
struct {
    int a;
    int b;
} test;

int main(){
    int err = 0;

    test.
    err++;

    test.
    err = err + 1;

    test.
    err--;
}

It's expected that pressing ctrl+space will give us a tooltip, but the first and third "test." the hint doesn't appear, it only works for the second one. ++, --, +=, -=, *=, /=, |=, &=, and ^=/ have similar behavior.

Configuration and Logs
loggingLevel: 6
loggingLevel был изменен на: Debug
Обработан файл c_cpp_properties.json за 0.0065977 с
Intellisense update pending for: file:///c%3A/prog/c/bugTest/main.c
Завершение работы сервера IntelliSense: C:\prog\c\bugTest\main.c
LSP: (received) cpptools/didChangeCppProperties (id: 453)
LSP: (invoked) cpptools/didChangeCppProperties (id: 453)
Попытка получить значения по умолчанию из компилятора C++ в свойстве "compilerPath": "cl.exe"
Попытка получить значения по умолчанию из компилятора C в свойстве "compilerPath": "cl.exe"
  Папка C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\18\BUILDTOOLS\VC\TOOLS\MSVC\14.50.35717\INCLUDE будет индексироваться
  Папка C:\PROG\C\BUGTEST будет индексироваться
LSP: Sending response (id: 453)
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/prog/c/bugTest/main.c (id: 454)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/prog/c/bugTest/main.c (id: 454)
LSP: Sending response (id: 454)
LSP: (received) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 455)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 455)
LSP: Sending response (id: 455)
LSP: $/cancelRequest (<unknown/completed>, id: 455)
LSP: (received) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 456)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 456)
LSP: Sending response (id: 456)
IntelliSense update scheduled and TU acquisition started for: file:///c%3A/prog/c/bugTest/main.c
Populating file name cache...
Done populating filename cache. Elapsed time: 0 ms
Expanding recursive includes for: C:\PROG\C\BUGTEST\MAIN.C
Done expanding recursive includes for: C:\PROG\C\BUGTEST\MAIN.C
Reducing recursive includes for: C:\PROG\C\BUGTEST\MAIN.C
Done reducing recursive includes for: C:\PROG\C\BUGTEST\MAIN.C
Отправка аргументов компиляции для C:\prog\c\bugTest\main.c.
  system include: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\18\BUILDTOOLS\VC\TOOLS\MSVC\14.50.35717\INCLUDE
  define: _DEBUG
  define: UNICODE
  define: _UNICODE
  stdver: ms_c17
  intelliSenseMode: windows-msvc-x64
Время обновления IntelliSense (в секундах): 0.038
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/prog/c/bugTest/main.c (id: 457)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/prog/c/bugTest/main.c (id: 457)
LSP: Sending response (id: 457)
LSP: (received) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 458)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 458)
LSP: Sending response (id: 458)
LSP: (received) cpptools/getFoldingRanges: file:///c%3A/prog/c/bugTest/main.c (id: 459)
LSP: (invoked) cpptools/getFoldingRanges: file:///c%3A/prog/c/bugTest/main.c (id: 459)
LSP: Sending response (id: 459)
LSP: (received) cpptools/didChangeActiveEditor: file:///c%3A/prog/c/bugTest/main.c
LSP: (invoked) cpptools/didChangeActiveEditor: file:///c%3A/prog/c/bugTest/main.c
LSP: (received) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 460)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 460)
LSP: Sending response (id: 460)
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeVisibleTextEditors
LSP: (invoked) cpptools/didChangeVisibleTextEditors
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 461)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 461)
LSP: Sending response (id: 461)
LSP: (received) textDocument/completion: file:///c%3A/prog/c/bugTest/main.c (id: 462)
LSP: (invoked) textDocument/completion: file:///c%3A/prog/c/bugTest/main.c (id: 462)
auto_complete::handle_completion: file:///c%3A/prog/c/bugTest/main.c (9:10)
Предлагается завершение.
LSP: Sending response (id: 462)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 463)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 463)
LSP: Sending response (id: 463)
LSP: (received) textDocument/completion: file:///c%3A/prog/c/bugTest/main.c (id: 464)
LSP: (invoked) textDocument/completion: file:///c%3A/prog/c/bugTest/main.c (id: 464)
auto_complete::handle_completion: file:///c%3A/prog/c/bugTest/main.c (12:10)
Предлагается завершение.
LSP: Sending response (id: 464)
LSP: (received) completionItem/resolve (id: 465)
LSP: (invoked) completionItem/resolve (id: 465)
LSP: Sending response (id: 465)
LSP: (received) cpptools/didChangeTextEditorSelection
LSP: (invoked) cpptools/didChangeTextEditorSelection
LSP: (received) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 466)
LSP: (invoked) cpptools/getCodeActions: file:///c%3A/prog/c/bugTest/main.c (id: 466)
LSP: Sending response (id: 466)
LSP: (received) textDocument/completion: file:///c%3A/prog/c/bugTest/main.c (id: 467)
LSP: (invoked) textDocument/completion: file:///c%3A/prog/c/bugTest/main.c (id: 467)
auto_complete::handle_completion: file:///c%3A/prog/c/bugTest/main.c (15:10)
Предлагается завершение.
LSP: Sending response (id: 467)
Other Extensions

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in main.c using the three test. completion locations and the listed operators, then trace the textDocument/completion requests through auto_complete::handle_completion. Compare why completion appears at the second location but not the first or third. Done means structure-field hints appear consistently for the reported contexts and operators.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.