Rules: comments: Fix bug when multi-line scalar

YAML content like the following one produced an error, because the
ScalarToken associated whose value is "this is plain text" ends at the
beginning of the 5th line (the one with the comment):

    ---
    string: >
      this is plain text

    # comment
This commit is contained in:
Adrien Vergé
2016-01-20 08:38:14 +01:00
parent 6a24781f96
commit 847f7e3fff
2 changed files with 23 additions and 5 deletions

View File

@@ -131,3 +131,19 @@ class CommentsTestCase(RuleTestCase):
' require-starting-space: yes\n'
' min-spaces-from-content: 2\n')
self.check('# comment\n', conf)
def test_multi_line_scalar(self):
conf = ('comments:\n'
' require-starting-space: yes\n'
' min-spaces-from-content: 2\n'
'trailing-spaces: disable\n')
self.check('---\n'
'string: >\n'
' this is plain text\n'
'\n'
'# comment\n', conf)
self.check('---\n'
'- string: >\n'
' this is plain text\n'
' \n'
' # comment\n', conf)