Fix indentation rule for key following empty list

If a key-value pair follows an empty list, i.e.:

```yaml
a:
-
b: c
```

yamllint will complain:

```
warning  wrong indentation: expected 2 but found 0  (indentation)
```

This is because it is expecting the second key to be a continuation of
the block entry above:

```yaml
a:
-
  b: c
```

However, both are perfectly valid, though structurally different.
pull/68/merge
Tim Wade 7 years ago committed by Adrien Vergé
parent c8fc170ff0
commit ca540c113b

@ -589,6 +589,9 @@ class IndentationTestCase(RuleTestCase):
' date: 1969\n' ' date: 1969\n'
' - name: Linux\n' ' - name: Linux\n'
' date: 1991\n' ' date: 1991\n'
' k4:\n'
' -\n'
' k5: v3\n'
'...\n', conf) '...\n', conf)
conf = 'indentation: {spaces: 2, indent-sequences: true}' conf = 'indentation: {spaces: 2, indent-sequences: true}'
self.check('---\n' self.check('---\n'

@ -399,6 +399,10 @@ def _check(conf, token, prev, next, nextnext, context):
# - item 1 # - item 1
# - item 2 # - item 2
indent = next.start_mark.column indent = next.start_mark.column
elif next.start_mark.column == token.start_mark.column:
# -
# key: value
indent = next.start_mark.column
else: else:
# - # -
# item 1 # item 1

Loading…
Cancel
Save