X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/f50ba078b3f15b3292f01b76f5c0f4209a57f8c7..6fdbdb4ee301d8f9466da4da8364ac05611a1b19:/black.py diff --git a/black.py b/black.py index 18d60c0..1978fd5 100644 --- a/black.py +++ b/black.py @@ -2145,15 +2145,21 @@ def list_comments(prefix: str, *, is_endmarker: bool) -> List[ProtoComment]: consumed = 0 nlines = 0 + ignored_lines = 0 for index, line in enumerate(prefix.split("\n")): consumed += len(line) + 1 # adding the length of the split '\n' line = line.lstrip() if not line: nlines += 1 if not line.startswith("#"): + # Escaped newlines outside of a comment are not really newlines at + # all. We treat a single-line comment following an escaped newline + # as a simple trailing comment. + if line.endswith("\\"): + ignored_lines += 1 continue - if index == 0 and not is_endmarker: + if index == ignored_lines and not is_endmarker: comment_type = token.COMMENT # simple trailing comment else: comment_type = STANDALONE_COMMENT