[vcFormat] Extra spaces around `=` are removed if `space.aroundAssignmentOperator` is set to `insert`
还没有人认领这个 Issue。
评估
调研方向
首先定位 C_Cpp.vcFormat.space.aroundAssignmentOperator 的 vcFormat 实现和测试。在设置为 insert 的 .c 文件中复现 enum 示例,然后验证格式化器在处理没有空格的一侧时仍会保留现有的对齐空格。
由索引模型根据 Issue 内容生成。
描述
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 C_Cpp.vcFormat.space.aroundAssignmentOperator is set to insert, vcFormat will remove all extra spaces around an assignment operator leaving exactly one space on each side. However, there many times where extra spaces are warranted for the sake of columnar alignment to improve readability.
Therefore, I believe there are two possible solutions to this problem:
- Change the behavior of
insertso that it only modifies the file by adding a space if no space is present on a side of the assignment operator - Remove the
insertandremoveoptions and replace them with the following options (retaining theignoreoption):none: Formatter will remove spaces from both sides of the assignment operatorone: Formatter will add or remove spaces from both sides of the assignment operator so that the result is one space on each side of the assignment operatoroneOrMore: Formatter will only add one space to a side of the assignment operator if zero spaces exist on that side. If one or more spaces exist, the formatter will not make any changes.
Steps to reproduce:
- Ensure
C_Cpp.vcFormat.space.aroundAssignmentOperatoris set toinsert - Add the following lines to a .c file:
enum {
short_name = 0x00,
longer_name = 0x01,
even_longer_name = 0x02,
another_longer_name = 0x04,
shorter_name = 0x08,
};
- Format the file using vcFormat
Expected behavior:
- The file should not change
Actual output:
enum {
short_name = 0x00,
longer_name = 0x01,
even_longer_name = 0x02,
another_longer_name = 0x04,
shorter_name = 0x08,
};
Configuration and Logs
N/A
Other Extensions
No response
Additional context
No response
- 主要语言
- TypeScript
- 星标
- 6.2k
- 派生
- 1.7k
- 平均合并
- 14 小时 46 分钟
- 30 天内合并 PR
- 61
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/vscode-cpptools 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
microsoft/vscode-cpptools#14787 ·
-
[Bug] cpptools fails to start on Ubuntu ARM64 due to missing execute permissions on shared libraries 未关闭bug fixed Language Service regression
microsoft/vscode-cpptools#14779 · 已指派 1 人 ·
-
Language Service more info needed
microsoft/vscode-cpptools#14778 · 1 条评论 · 已指派 1 人 ·
-
难度 4/5 3-5 天 新手友好度 64/100
microsoft/vscode-cpptools#14769 ·
-
难度 3/5 1-2 天 新手友好度 68/100
microsoft/vscode-cpptools#14768 · 1 条评论 ·
查看 microsoft/vscode-cpptools 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 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
难度 2/5 1-3 小时 新手友好度 78/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
-
calcite-components needs triage refactor
难度 2/5 1-3 小时 新手友好度 75/100
Esri/calcite-design-system#15203 ·
-
难度 2/5 1-3 小时 新手友好度 90/100
danielmiessler/LifeOS#2218 ·