microsoft / microsoft/vscode-cpptools

vcFormat incorrectly formatting templated operator() call

Open
#11,159 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Feature: Code Formatting Language Service 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_NT x64 10.0.19045
  • VS Code Version: 1.79.2
  • C/C++ Extension Version: v1.16.3
Bug Summary and Steps to Reproduce

Settings:

"C_Cpp.default.cppStandard": "c++23",
"C_Cpp.default.cStandard": "c17",
"C_Cpp.default.intelliSenseMode": "windows-gcc-x64",
"C_Cpp.default.compilerPath": "C:\msys64\ucrt64\bin\g++.exe",
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.suggestSnippets": false,
"C_Cpp.formatting": "vcFormat",
"C_Cpp.vcFormat.wrap.preserveBlocks": "allOneLineScopes",
"C_Cpp.vcFormat.indent.gotoLabels": "oneLeft",
"C_Cpp.vcFormat.indent.caseLabels": true,
"C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyFunction": true,
"C_Cpp.vcFormat.newLine.closeBraceSameLine.emptyType": true,
"C_Cpp.vcFormat.indent.multiLineRelativeTo": "statementBegin",
"C_Cpp.vcFormat.newLine.beforeElse": false,
"C_Cpp.vcFormat.newLine.beforeCatch": false,
"C_Cpp.vcFormat.space.withinInitializerListBraces": false,
"C_Cpp.vcFormat.indent.preserveWithinParentheses": true,
"C_Cpp.vcFormat.space.pointerReferenceAlignment": "right",
"C_Cpp.vcpkg.enabled": false,
"C_Cpp.default.defines": [],
"C_Cpp.simplifyStructuredComments": false,
"C_Cpp.errorSquiggles": "disabled",
"C_Cpp.codeAnalysis.runAutomatically": false,
"C_Cpp.dimInactiveRegions": false,
"C_Cpp.intelliSenseEngine": "Tag Parser",
"C_Cpp.vcFormat.indent.lambdaBracesWhenParameter": false

Code before formatting (expected behavior):

#include <functional>

int main() {
	std::less<void> comparator;
	comparator.operator()<int, int>(5, 5);
}

Code after formatting:

#include <functional>

int main() {
	std::less<void> comparator;
	comparator.operator() < int, int > (5, 5);
}
Configuration and Logs
loggingLevel: Debug
loggingLevel has changed to: Debug
LSP: cpptools/textEditorSelectionChange
LSP: textDocument/didOpen: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp
LSP: cpptools/activeDocumentChange: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp
Checking for syntax errors: C:\Users\Aleksandras\Desktop\projects\QAP_BA\src\format.cpp
LSP: cpptools/getCodeActions: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 634)
LSP: cpptools/getDocumentSymbols: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 635)
Queueing IntelliSense update for files in translation unit of: C:\Users\Aleksandras\Desktop\projects\QAP_BA\src\format.cpp
LSP: cpptools/textEditorSelectionChange
LSP: cpptools/getSemanticTokens: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 636)
LSP: cpptools/getInlayHints: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 637)
Database safe to open.
Error squiggle count: 0
Update IntelliSense time (sec): 0.438
LSP: textDocument/willSaveWaitUntil: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 638)
willSaveWaitUntil: 0ms
LSP: cpptools/formatDocument: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 639)
Formatting document: file:///C%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp
Formatting Engine: vcFormat
LSP: textDocument/didChange: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp
LSP: textDocument/didSave: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp
  tag parsing file: C:\Users\Aleksandras\Desktop\projects\QAP_BA\src\format.cpp
LSP: cpptools/fileChanged: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp
LSP: cpptools/getDocumentSymbols: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 640)
LSP: cpptools/getSemanticTokens: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 641)
LSP: cpptools/getInlayHints: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 642)
idle loop: reparsing the active document
Checking for syntax errors: C:\Users\Aleksandras\Desktop\projects\QAP_BA\src\format.cpp
Queueing IntelliSense update for files in translation unit of: C:\Users\Aleksandras\Desktop\projects\QAP_BA\src\format.cpp
sending 4 changes to server
Error squiggle count: 0
Update IntelliSense time (sec): 0.277
Checking for syntax errors: C:\Users\Aleksandras\Desktop\projects\QAP_BA\src\format.cpp
Queueing IntelliSense update for files in translation unit of: C:\Users\Aleksandras\Desktop\projects\QAP_BA\src\format.cpp
Error squiggle count: 0
Update IntelliSense time (sec): 0.256
LSP: cpptools/getSemanticTokens: file:///c%3A/Users/Aleksandras/Desktop/projects/QAP_BA/src/format.cpp (id: 643)
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

Start at the vcFormat formatting path and reproduce the reported C++ operator() call with the settings and before/after output in the issue. Trace how the templated call is classified, then verify that formatting preserves the expected operator syntax without spaces around its template arguments.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.