Skip to content

Conversation

@Valdeirsk8
Copy link

@Valdeirsk8 Valdeirsk8 commented Jan 18, 2026

This PR implements the wrap_single_statement_if feature, allowing single-statement if and else blocks to be automatically wrapped in begin...end blocks while maintaining correct logical line structure and indentation.

Key Changes

Configuration: Added wrap_single_statement_if setting to FormattingConfig.
Parser Refactor: Completely refactored wrap_if_blocks in parser.rs to perform physical logical line splitting for injected begin and end tokens.
Indentation Logic: Synchronized parent/level assignments to ensure injected blocks match pasfmt native indentation (aligning begin/end with the control statement).
Core Improvements: Added set_level and set_parent methods to LogicalLine in lang.rs to support dynamic restructuring.
Tests: Expanded unit tests in if_wrap_tests.rs and updated integration test data.

this was created using vibe coding and gemini 3, and tested in a one million lines of legacy project.

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.

1 participant