style: Convert leading spaces to tabs in Core engine and libraries#2565
style: Convert leading spaces to tabs in Core engine and libraries#2565bobtista wants to merge 6 commits intoTheSuperHackers:mainfrom
Conversation
|
| Filename | Overview |
|---|---|
| scripts/cpp/convert_leading_spaces_to_tabs.py | New script that generated the whitespace conversion; logic is sound (same-length macro substitutions, tree-sitter AST-based depth calculation, correct block-comment tracking), but whether it should be committed is ambiguous given the PR description. |
| Core/GameEngine/Source/Common/Audio/simpleplayer.cpp | 994 lines reformatted; all changes are leading-space → tab substitutions only (confirmed by git diff -w). |
| Core/GameEngine/Source/Common/Audio/urllaunch.cpp | 596 lines reformatted; purely whitespace changes, no functional differences. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp | Whitespace-only reformatting of W3D view implementation; no logic changes. |
| Core/GameEngine/Include/GameClient/TerrainVisual.h | 198-line whitespace reformatting of terrain visual header; no code changes. |
| Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp | Whitespace-only reformatting; indentation converted to tabs throughout. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Read file with cp1252 encoding] --> B[Parse with tree-sitter C++ after macro expansion]
B --> C{Too many top-level ERROR nodes?}
C -- yes --> D[Skip file entirely]
C -- no --> E[For each line...]
E --> F{In block comment?}
F -- yes --> G[Preserve as-is, check for closing]
F -- no --> H{Starts with /*?}
H -- yes --> I[Preserve as-is, set in_block_comment if needed]
H -- no --> J{In macro continuation?}
J -- yes --> K[Preserve as-is]
J -- no --> L{Blank line or preprocessor?}
L -- yes --> M[Preserve as-is]
L -- no --> N{Already uses tabs?}
N -- yes --> O[Preserve as-is]
N -- no --> P[Find AST node at first non-whitespace col]
P --> Q{Node inside ERROR ancestor?}
Q -- yes --> R[Skip - preserve as-is]
Q -- no --> S{Continuation line?}
S -- yes --> T[depth = parent_depth + 1, or parent_depth if closing delim]
S -- no --> U[depth = get_indent_depth node]
T --> V{depth==0 but >= 4 leading spaces?}
U --> V
V -- yes --> W[Skip - sanity check failed]
V -- no --> X[Replace leading whitespace with depth tabs]
X --> Y[Write file if any lines changed]
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-16
Comment:
**Script committed despite "not intended to be merged" note**
The PR description states the script is included "for reference but is not intended to be merged," yet it is committed to `scripts/cpp/` — the same directory that holds all other community formatting tools (`apply_code_formatting.py`, `harmonize_linebreaks_pragmaonce.py`, etc.). If the intent is truly to keep it out of the repository history, it should be removed before merging; if it should live alongside the other scripts (which seems more consistent with the repo convention), the PR description should be updated to reflect that.
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