microsoft / microsoft/vscode-cpptools
Header-only IntelliSense should use language ID delivered with `didOpen` instead of defaulting to C++
Open
Nobody has claimed this yet.
bug
Language Service
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Bug type: Language Service
Describe the bug
- OS and Version: linux 5.17.1
- VS Code Version: 1.65.2
- C/C++ Extension Version: 1.9.7
- Other extensions you installed (and if the issue persists after disabling them): dart, go, flutter, python, rust (literal names of the extensions)
- If using SSH remote, specify OS of remote machine:
- A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc). Workspace is a project with a lot of go code and one file in c, a header file with just one line. This file is located at x/y.h. and contains
void z(char *restrict q);which is valid C code. Language is set to C.
Steps to reproduce
- Open x/y.h
- See error
Expected behavior
No squiggly lines
Code sample and logs
- Code sample
void z(char *restrict q);
-
Configurations in
c_cpp_properties.json -
Logs from running
C/C++: Log Diagnosticsfrom the VS Code command palette
-------- Diagnostics - 04/04/2022, 19:07:04
Version: 1.9.7
Current Configuration:
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/sbin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64",
"compilerArgs": [],
"intelliSenseModeIsExplicit": false,
"cStandardIsExplicit": false,
"cppStandardIsExplicit": false,
"mergeConfigurations": false,
"compilerPathIsExplicit": false,
"browse": {
"path": [
"${workspaceFolder}/**"
],
"limitSymbolsToIncludedHeaders": true
}
}
Translation Unit Mappings:
[ /.../x/y.h ]:
/.../x/y.h
Translation Unit Configurations:
[ /.../x/y.h ]:
Process ID: 17136
Memory Usage: 12 MB
Compiler Path: /sbin/clang
Includes:
/usr/include/c++/11.2.0
/usr/include/c++/11.2.0/x86_64-pc-linux-gnu
/usr/include/c++/11.2.0/backward
/usr/lib/clang/13.0.1/include
/usr/local/include
/usr/include
Standard Version: c++14
IntelliSense Mode: linux-clang-x64
Other Flags:
--clang
--clang_version=130001
--header_only_fallback
Total Memory Usage: 12 MB
------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 26971
Number of files parsed: 3712
- Logs from [the language server logging](https://code.visualstudio.com/docs/cpp/enable-logging-cpp#_enable-logging-for-the-language-server)
loggingLevel: Debug
loggingLevel has changed to: Debug
cpptools/didChangeCppProperties
$/setTraceNotification
cpptools/getCodeActions: /.../x/y.h (id: 149)
cpptools/textEditorSelectionChange
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: /.../x/y.h
cpptools/getFoldingRanges: /.../x/y.h (id: 150)
cpptools/getCodeActions: /.../x/y.h (id: 151)
textDocument/didClose: /.../x/y.h
Database safe to open
cpptools/getCodeActions: /.../x/y.h (id: 152)
textDocument/didOpen: /.../x/y.h
Checking for syntax errors: /.../x/y.h
Queueing IntelliSense update for files in translation unit of: /.../x/y.h
cpptools/textEditorSelectionChange
cpptools/getDocumentSymbols: /.../x/y.h (id: 153)
cpptools/textEditorSelectionChange
cpptools/getSemanticTokens: /.../x/y.h (id: 154)
cpptools/getDocumentSymbols
cpptools/activeDocumentChange: /.../x/y.h
cpptools/getFoldingRanges: /.../x/y.h (id: 155)
cpptools/getCodeActions: /.../x/y.h (id: 156)
cpptools/finishUpdateSquiggles
Error squiggle count: 1
terminating child process: 18585
Update IntelliSense time (sec): 0.367
cpptools/getCodeActions: /.../x/y.h(id: 157)
cpptools/getFoldingRanges: /.../x/y.h (id: 158)
cpptools/textEditorSelectionChange
cpptools/activeDocumentChange: /.../x/y.h
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the textDocument/didOpen handling shown in the language-server log and the header_only_fallback configuration in the diagnostics. Verify how the delivered language ID is used for x/y.h, then reproduce the C header case and confirm that valid C syntax no longer receives C++-specific squiggles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, typescript
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100