style: Convert leading spaces to tabs in GeneralsMD GameEngine#2569
style: Convert leading spaces to tabs in GeneralsMD GameEngine#2569bobtista wants to merge 6 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| scripts/cpp/convert_leading_spaces_to_tabs.py | New formatting script added for reference; PR description states it is "not intended to be merged" but it is included in the diff and will be committed |
| GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h | Whitespace-only change (spaces → tabs); inline block comment continuation lines lost visual alignment with the opening text |
| GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp | Whitespace-only change; multi-line for-loop header continuation lines are now at parent depth rather than parent+1, consistent with how the script handles them across the PR |
| GeneralsMD/Code/GameEngine/Include/GameClient/Eva.h | Whitespace-only: mixed-indented enum members converted to consistent tabs; no semantic changes |
| GeneralsMD/Code/GameEngine/Include/Common/BitFlags.h | Whitespace-only: previously mixed space/tab indentation (spaces at outer, tabs at inner) converted to consistent tabs throughout |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read .cpp / .h file\ncp1252 encoding] --> B{Line type?}
B -->|Block comment interior| C[Preserve as-is]
B -->|Macro continuation| C
B -->|Blank line| C
B -->|Preprocessor directive| C
B -->|Already tab-indented| C
B -->|Has leading spaces| D[Find AST node\nvia tree-sitter]
D --> E{Parse error\nor ERROR node?}
E -->|Yes| C
E -->|No| F{Continuation line?}
F -->|Yes| G[depth = parent_depth + 1\nclosing delimiters: parent_depth]
F -->|No| H[depth = get_indent_depth node]
G --> I{Sanity check:\ndepth == 0 and spaces >= 4?}
H --> I
I -->|Fail| C
I -->|Pass| J[Output: depth x tab + content]
J --> K[Write file\ncp1252 encoding]
Prompt To Fix All With AI
This is a comment left during a code review.
Path: scripts/cpp/convert_leading_spaces_to_tabs.py
Line: 1
Comment:
**Script committed despite "not intended to be merged"**
The PR description explicitly states this script is "included for reference but is not intended to be merged," yet it appears in the diff and will be committed to the repository. Other prior formatting scripts (e.g. `apply_code_formatting.py`, `remove_include_guards_pragma.py`) were also committed, so this is likely intentional, but the description is misleading. Please clarify whether the file should be committed (consistent with the pattern in `scripts/cpp/`) or excluded from this PR.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
Line: 396-399
Comment:
**Inline block comment continuation alignment broken**
The `/** … */` comment that opens mid-line on the `m_groupMoveClickToGatherFactor` declaration had its continuation lines aligned with the opening text. After conversion those lines are now indented to depth 1 (one tab), detached from the `/**` opener and visually broken. This happens because the script only sets `in_block_comment = True` when a line *starts* with `/*`, so mid-line openers are not detected and their continuations are treated as regular code.
This is the only occurrence of this pattern in the changed files, so no wider fix is needed — just a manual restore of the original continuation spacing for this comment block.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
Line: 506-507
Comment:
**For-loop continuation lines at same depth as the `for` statement**
Multi-line `for`-header continuations (condition/increment on a second line) are indented to the same depth as the `for` keyword itself rather than the expected parent+1. For example:
```cpp
for( PlayerTeamList::iterator it = m_playerTeamPrototypes.begin();
it != m_playerTeamPrototypes.end(); ++it) // same indent as 'for'
```
The script's `get_continuation_parent` path would give `depth = parent_depth + 1 = 2`, but the output shows depth 1. This suggests these lines were not classified as continuations and fell through to `get_indent_depth(node)` (which returns 1, same as the `for` itself). The same pattern appears across all files in this PR that have multi-line `for` headers (e.g. `Player.cpp` lines 1729 and 1756, 1780).
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "style: Convert leading spaces to tabs in..." | Re-trigger Greptile
Summary
git diff -wis empty)Continuation lines (multi-line function args, constructor initializer lists,
multi-line conditions, etc.) are indented at parent statement depth + 1 tab.
Closing delimiters on their own line go at parent depth.
Script
The formatting script is included in the PR for reference but is not intended
to be merged — it shows how the changes were generated.
See
scripts/cpp/convert_leading_spaces_to_tabs.pyfor details.All parts