Rules: indentation: Handle imbricated flows correctly

The following source -- although not loadable by pyyaml -- is valid
YAML:

    {{key}}: value

This was processed badly by yamllint. The same for `[[value]]`,
`{{{{{moustaches}}}}}` or:

    {[val,
      {{key: val,
        key2}}]}

This patch corrects it and add corresponding test cases.

Related-to: #3
This commit is contained in:
Adrien Vergé
2016-03-21 21:58:54 +01:00
parent f98bed1085
commit 76f47e91ca
2 changed files with 183 additions and 2 deletions

View File

@@ -497,12 +497,16 @@ def _check(conf, token, prev, next, nextnext, context):
consumed_current_token = False
while True:
if (context['stack'][-1].type == F_SEQ and
isinstance(token, yaml.FlowSequenceEndToken)):
isinstance(token, yaml.FlowSequenceEndToken) and
not consumed_current_token):
context['stack'].pop()
consumed_current_token = True
elif (context['stack'][-1].type == F_MAP and
isinstance(token, yaml.FlowMappingEndToken)):
isinstance(token, yaml.FlowMappingEndToken) and
not consumed_current_token):
context['stack'].pop()
consumed_current_token = True
elif (context['stack'][-1].type in (B_MAP, B_SEQ) and
isinstance(token, yaml.BlockEndToken) and