]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Don't fold postscriptum standalone comment into last statement
authorŁukasz Langa <lukasz@langa.pl>
Sat, 17 Mar 2018 07:54:30 +0000 (00:54 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Sat, 17 Mar 2018 07:59:28 +0000 (00:59 -0700)
This happened when the last statement was a simple statement.

Fixes #18
Fixes #28

README.md
black.py
tests/expression.py

index 0ccef300630c34294b3d7d198dd361ca80a320a8..38b27e51f15cd7668281215daa1cb67321a709d7 100644 (file)
--- 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)
index 89155f60103a32e2f89cd86ac1e6c92aa1bed22f..f305e8dd79e66d76168e16e06c3fc4302e6c61e1 100644 (file)
--- 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
index 87a03f6baac79c8cc7dee5fe0a8a781dfef63586..d90b7cfa799e2a0b6bc3de745c780964035ea9f3 100644 (file)
@@ -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