comments: Fix ignore-shebangs option on corner cases

This commit is contained in:
Adrien Vergé
2019-01-11 12:19:06 +01:00
parent b77f78f677
commit b4740dc1fb
2 changed files with 23 additions and 5 deletions

View File

@@ -64,6 +64,8 @@ Use this rule to control the position and formatting of comments.
"""
import re
from yamllint.linter import LintProblem
@@ -92,7 +94,8 @@ def check(conf, comment):
if text_start < len(comment.buffer):
if (conf['ignore-shebangs'] and
comment.line_no == 1 and
comment.buffer[text_start] == '!'):
comment.column_no == 1 and
re.match(r'^!\S', comment.buffer[text_start:])):
return
elif comment.buffer[text_start] not in (' ', '\n', '\0'):
column = comment.column_no + text_start - comment.pointer