Skip to content

style: Convert leading spaces to tabs in Generals#2562

Open
bobtista wants to merge 8 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/feat/access-spec-indent-generals
Open

style: Convert leading spaces to tabs in Generals#2562
bobtista wants to merge 8 commits intoTheSuperHackers:mainfrom
bobtista:bobtista/feat/access-spec-indent-generals

Conversation

@bobtista
Copy link
Copy Markdown

@bobtista bobtista commented Apr 9, 2026

Summary

  • Convert leading spaces/mixed whitespace to tabs, including access specifier indentation
  • All changes are whitespace-only (git diff -w is empty)
  • Uses tree-sitter-cpp for accurate C++ parsing with macro preprocessing

Access specifiers (public:/private:/protected:) are placed at the class
brace level, matching the existing codebase convention.

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.py for details.

Part 2 of 4 — Generals/ (425 files).
See also: #2561, #2563, #2564.

@greptile-apps
Copy link
Copy Markdown

greptile-apps bot commented Apr 9, 2026

Greptile Summary

This PR converts leading spaces (and mixed whitespace) to tabs across 470 files in Generals/ using a tree-sitter–based Python script. The core claim — that git diff -w is empty — has been verified: git diff -w across all changed C++ files produces exactly 0 bytes, confirming all changes are purely whitespace with no effect on code logic.

Confidence Score: 5/5

Safe to merge — all 470 C++ file changes are verified whitespace-only by git diff -w, with zero non-whitespace modifications.

git diff -w across all Generals/ files produces 0 bytes, conclusively confirming no logic changes. The sole new artifact is the reference Python script, which has only a minor edge-case P2 issue that does not affect the already-applied conversion.

scripts/cpp/convert_leading_spaces_to_tabs.py has a minor block-comment detection edge case, but this does not affect the correctness of any C++ file in this PR.

Important Files Changed

Filename Overview
scripts/cpp/convert_leading_spaces_to_tabs.py New reference script using tree-sitter for accurate C++ indentation analysis; contains a minor edge-case bug where a // comment containing /* without a closing */ can incorrectly set in_block_comment = True for subsequent lines
Generals/Code/GameEngine/Include/Common/BitFlags.h Whitespace-only conversion: leading spaces replaced with tabs; verified no non-whitespace changes by git diff -w
Generals/Code/GameEngine/Source/GameLogic/Object/Object.cpp Whitespace-only conversion: stray leading spaces and mixed space/tab indentation normalized to tabs; no logic changes
Generals/Code/GameEngine/Source/GameLogic/AI/AI.cpp Whitespace-only conversion; passes git diff -w check
Generals/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h Whitespace-only conversion; access specifiers placed at class-brace level per codebase convention
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: 409-414

Comment:
**`//` comment containing `/*` can incorrectly open block-comment state**

If a processed line contains `/*` inside a `//` comment with no matching `*/` on the same line (e.g. `foo(); // uses /* notation`), `in_block_comment` is set to `True`. The next line(s) will be treated as inside a block comment and skipped, until a `*/` is seen. This causes those lines to be silently left unconverted on future runs of the script.

Adding a guard for `//` comments before checking for `/*` would fix this:

```python
        # Track mid-line block comment opens (e.g. /**< trailing doc comments)
        line_comment_pos = stripped.find('//')
        last_open = stripped.rfind('/*')
        if last_open >= 0 and (line_comment_pos < 0 or last_open < line_comment_pos):
            after_open = stripped[last_open + 2:]
            if '*/' not in after_open:
                in_block_comment = True
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (4): Last reviewed commit: "style: Preserve indentation inside prepr..." | Re-trigger Greptile

Copy link
Copy Markdown

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ive only reviewed the first 100 files or so.


virtual void execute(); /**< The "main loop" of the game engine.
It will not return until the game exits. */
It will not return until the game exits. */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation here is an issue imho and should be resolved before this PR (or optionally in this PR) rather then after.

I think a multi-line comment needs to be above the parameter/function, i.e.

/** The "main loop" of the game engine.
    It will not return until the game exits. */
virtual void execute();

Or as java would do:

/**
 * The "main loop" of the game engine.
 * It will not return until the game exits.
 */
virtual void execute();

This is a much nicer way to do it and more in the style of a proper documentation comment.

Bool m_selectionFlashHouseColor ; /// skip the house color and just use white.

Real m_cameraAudibleRadius; ///< If the camera is being used as the position of audio, then how far can we hear?
Real m_groupMoveClickToGatherFactor; /** if you take all the selected units and calculate the smallest possible rectangle
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place documentation comment before field parameter

Bool m_isPrerequisite; ///< Is this thing considered in a prerequisite for any other thing?
Bool m_isBridge; ///< True if this model is a bridge.
Bool m_isBuildFacility; ///< is this the build facility for something? (calculated based on other template's prereqs)
Bool m_isBuildFacility; ///< is this the build facility for something? (calculated based on other template's prereqs)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect indentation

Object* m_obj;
Object* m_otherObj;
const Team* m_team;
CommandSourceType m_cmdSource;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation

const PolygonTrigger* m_polygon;
Int m_intValue; /// misc usage
DamageInfo m_damage;
const Waypoint* m_waypoint;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation

{
for( PlayerTeamList::const_iterator it = m_playerTeamPrototypes.begin();
it != m_playerTeamPrototypes.end(); ++it )
it != m_playerTeamPrototypes.end(); ++it )
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INcorrect indentation, a few more times in this file

for( DLINK_ITERATOR< Object > objIt = iterate_TeamMemberList();
objIt.done() == FALSE;
objIt.advance() )
objIt.done() == FALSE;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation

y < halfFootprintHeight + sampleResolution;
y += sampleResolution )
y < halfFootprintHeight + sampleResolution;
y += sampleResolution )
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation x2

{
MYEIP1:
mov eax, MYEIP1
mov eax, MYEIP1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation

{
MYEIP2:
mov eax, MYEIP2
mov eax, MYEIP2
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants