Skip to content

List indent fixing is broken #202

@Cougar

Description

@Cougar

1️⃣ Description

I have "valid" YAML file with not the best list indents and yamlfixer breaks it

📑 Steps to Reproduce

Steps to reproduce the behavior:

  1. When I have test.yml like this:
---

a:
  b:
  - 1
  - 2
  - 3
  c:
    4
  1. Then run that: yamlfixer --nochange --summary --diffto my.patch test.yml

  2. I get such change:

--- "test.yml"
+++ "test.yml-after"
@@ -2,7 +2,7 @@
 
 a:
   b:
-  - 1
+    - 1
   - 2
   - 3
   c:

2️⃣ Expected behavior

All lines with elements 1, 2 and 3 should be indented with two extra spaces like this:

---

a:
  b:
    - 1
    - 2
    - 3
  c:
    4

Diff should look like this:

--- "test.yml"
+++ "test.yml-after"
@@ -2,8 +2,8 @@
 
 a:
   b:
-  - 1
-  - 2
-  - 3
+    - 1
+    - 2
+    - 3
   c:
     4

# ℹ️ Environment details

 - OS: `openSUSE Leap 15.4`
 - Python runtime: `3.10.10`
 - The output of `yamlfixer --version`: `yamlfixer v0.9.15`
 - Used shell: bash
 
# Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions