X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/82198030eef6f99ad47470d82c34d9a6e1a4e6df..54d707e10a5bf3d8d352c1bcbc7946bb6f3c01d7:/black.py diff --git a/black.py b/black.py index da645a1..15a7547 100644 --- a/black.py +++ b/black.py @@ -1158,7 +1158,16 @@ class LineGenerator(Visitor[Line]): def visit_DEDENT(self, node: Node) -> Iterator[Line]: """Decrease indentation level, maybe yield a line.""" - # DEDENT has no value. Additionally, in blib2to3 it never holds comments. + # The current line might still wait for trailing comments. At DEDENT time + # there won't be any (they would be prefixes on the preceding NEWLINE). + # Emit the line then. + yield from self.line() + + # While DEDENT has no value, its prefix may contain standalone comments + # that belong to the current indentation level. Get 'em. + yield from self.visit_default(node) + + # Finally, emit the dedent. yield from self.line(-1) def visit_stmt(