Skip to content

Detect indentation from existing YAML in MigrateToRules#39

Open
scuba10steve wants to merge 1 commit intomainfrom
scuba10steve/fix-indent-detection
Open

Detect indentation from existing YAML in MigrateToRules#39
scuba10steve wants to merge 1 commit intomainfrom
scuba10steve/fix-indent-detection

Conversation

@scuba10steve
Copy link
Copy Markdown
Collaborator

Summary

  • MigrateToRules hardcoded 2-space indent increments when building the replacement rules: block, producing mixed indentation on files using 4-space (or other) indent widths
  • Added detectIndentUnit() helper that compares the only:/except: entry prefix with its first sequence child prefix to determine the actual indent increment, falling back to 2-space when detection isn't possible
  • contentIndent (for when: never inside sequence items) remains a fixed 2-space offset from the sequence dash, matching YAML's block sequence content alignment

Test plan

  • Three new tests for 4-space indentation: only, except, and combined only+except
  • All 77 existing tests continue to pass unchanged
  • ./gradlew build passes

MigrateToRules hardcoded 2-space indent increments when building the
replacement rules block, producing mixed indentation on files using
4-space or other indent widths. Detect the actual indent unit by
comparing the only/except entry prefix with its first sequence child
prefix, falling back to 2-space when detection is not possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant