From: Ɓukasz Langa Date: Sat, 17 Mar 2018 07:54:30 +0000 (-0700) Subject: Don't fold postscriptum standalone comment into last statement X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/68c71b621f5c80c243ba8a177c5a2059b3ace1d9 Don't fold postscriptum standalone comment into last statement This happened when the last statement was a simple statement. Fixes #18 Fixes #28 --- diff --git a/README.md b/README.md index 0ccef30..38b27e5 100644 --- a/README.md +++ b/README.md @@ -272,6 +272,11 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md). * if top level functions were separated by a comment, don't put four empty lines after the upper function +* fixed unstable formatting of newlines with imports + +* fixed unintentional folding of post scriptum standalone comments + into last statement if it was a simple statement (#18, #28) + * fixed missing space in numpy-style array indexing (#33) * fixed spurious space after star-based unary expressions (#31) diff --git a/black.py b/black.py index 89155f6..f305e8d 100644 --- a/black.py +++ b/black.py @@ -1115,7 +1115,7 @@ def generate_comments(leaf: Leaf) -> Iterator[Leaf]: if content and (content[0] not in {' ', '!', '#'}): content = ' ' + content is_standalone_comment = ( - '\n' in before_comment or '\n' in content or leaf.type == token.DEDENT + '\n' in before_comment or '\n' in content or leaf.type == token.ENDMARKER ) if not is_standalone_comment: # simple trailing comment diff --git a/tests/expression.py b/tests/expression.py index 87a03f6..d90b7cf 100644 --- a/tests/expression.py +++ b/tests/expression.py @@ -124,6 +124,9 @@ if ( signal.getsignal(signal.SIGINT) != signal.default_int_handler ): return True +last_call() +# standalone comment at ENDMARKER + # output @@ -275,3 +278,6 @@ if ( or signal.getsignal(signal.SIGINT) != signal.default_int_handler ): return True + +last_call() +# standalone comment at ENDMARKER