[vcFormat] `space.withinInitializerListBraces`/`space.withinSquareBrackets` are not heeded inside array initialization
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 56/100
Research direction
Start by reproducing the issue in a .c file with vcFormat and the relevant space.withinInitializerListBraces or space.withinSquareBrackets setting enabled. Trace how vcFormat handles the first designated initializer inside array initialization, then verify that formatting preserves the spaces shown in both expected examples.
Written by the indexing model from the issue text.
Description
Environment
- OS and Version: Various (assuming all)
- VS Code Version: 1.117.0
- C/C++ Extension Version: 1.31.5
Bug Summary and Steps to Reproduce
Bug Summary:
When the setting C_Cpp.vcFormat.space.withinInitializerListBraces is set to true, vcFormat fails to add (and will actually remove) a space from between the opening brace and the first designated initializer of all struct members when part of the initialization of an array of structs.
Steps to reproduce:
- Ensure
C_Cpp.vcFormat.space.withinInitializerListBracesis set totrue - Add the following lines to a .c file:
typedef struct {
int member_a;
int member_b;
} MyStruct_t;
MyStruct_t array_of_structs[] = {
{ .member_a = 0, .member_b = 1 },
{ .member_a = 2, .member_b = 3 },
{ .member_a = 4, .member_b = 5 },
};
- Format the file using vcFormat
Expected behavior:
- The file should not change
Actual result:
typedef struct {
int member_a;
int member_b;
} MyStruct_t;
MyStruct_t array_of_structs[] = {
{.member_a = 0, .member_b = 1 },
{.member_a = 2, .member_b = 3 },
{.member_a = 4, .member_b = 5 },
};
The same problem also appears to afflict the first designated initializer of an array with spaces enabled inside square brackets. Here are steps to reproduce:
- Ensure
C_Cpp.vcFormat.space.withinSquareBracketsis set totrue - Add the following lines to a .c file:
int my_array[3] = {
[ 0 ] = 100,
[ 1 ] = 101,
[ 2 ] = 102,
};
- Format the file using vcFormat
Expected behavior:
- The file should not change
Actual result:
int my_array[3] = {
[0] = 100,
[ 1 ] = 101,
[ 2 ] = 102,
};
Configuration and Logs
Configurations vary; the pertinent configuration options are mentioned above.
Logs will be provided if deemed necessary. I believe this should be very easily reproduced.
Other Extensions
No response
Additional context
No response
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
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.
More from microsoft/vscode-cpptools
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
microsoft/vscode-cpptools#14787 ·
-
[Bug] cpptools fails to start on Ubuntu ARM64 due to missing execute permissions on shared libraries Openbug fixed Language Service regression
microsoft/vscode-cpptools#14779 · 1 assignee ·
-
Language Service more info needed
microsoft/vscode-cpptools#14778 · 1 comment · 1 assignee ·
-
Difficulty 4/5 3-5 days Newbie friendliness 64/100
microsoft/vscode-cpptools#14769 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
microsoft/vscode-cpptools#14768 · 1 comment ·
All issues in microsoft/vscode-cpptools
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
copse-dev/agent-pane#2953 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·