Unnecessary restriction

Issue #417 invalid
José M. Reigosa created an issue

SnakeYAML 1.23.

When using DumperOptions IndicatorIndent and Indent and setting both values to the same one, a YAMLException (Indicator indent must be smaller then indent) is thrown. There is no reason for such a restriction. Please, remove it.

Comments (8)

  1. Mikhail Kopylov

    @Andrey Somov I’ve my IntelliJ IDEA configured like this:

    • indent = 2
    • indent sequence value = true

    Here’s the screenshot:

    How can I configure snakeyaml not to reformat my yml files?

    I tried to configure indent=2 and indicatorIndent=2, but the validation fails with message Indicator indent must be smaller then indent.

    If I configure indent=6 and indicatorIndent=4 like it’s in https://bitbucket.org/asomov/snakeyaml/src/f437efd6719eaa93d616c7aca164a3d2d07f0031/src/test/java/org/yaml/snakeyaml/issues/issue358/UnexpectedIndentTest.java?at=default&fileviewer=file-view-default that will reformat simple maps

    type: Example config
    components:
      - name: First component
        description: Some short description of the first component
    
      - name: Second component
        description: Some short description of the second component
    
    simpleMap:
      key1: value1
      key2: value2  
    

  2. Mikhail Kopylov

    Thanks for the quick reply.

    The problem is I can’t make snakeyaml keep the IntelliJ IDEA format that is in screenshot (or code block, its' the same)

    If I configure indent=4 and indicatorIndent=2 then the result look this way

    type: Example config
    components:
      - name: First component
        description: Some short description of the first component
    
      - name: Second component
        description: Some short description of the second component
    
    simpleMap:
        key1: value1
        key2: value2  
    

    But I want to have indent=2 for simpleMap

    But I can’t have indicatorIndent greater or equal to indent

  3. Andrey Somov

    Since indicator is before the key, the indicatorIndent is always smaller than indent.

    Unfortunately, it is very difficult to design the API in such a way that it fits all the use cases. The current settings do not allow it.

    Feel free to make a proposal to improve the code !

  4. Andrey Somov

    This issue is dead. Create another one with a proposal when you have it.

    Or you can try to implement it in SnakeYAML Engine which is even better. You do not have backwards-compatibility problem.

  5. Log in to comment