X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/f87df0e3c8735de416b6392ce7f21c6ba194424d..9ce100ba61b6738298d86818a3d0eee7b18bfed7:/src/black/comments.py diff --git a/src/black/comments.py b/src/black/comments.py index 4553264..23bf87f 100644 --- a/src/black/comments.py +++ b/src/black/comments.py @@ -214,8 +214,11 @@ def generate_ignored_nodes( container: Optional[LN] = container_of(leaf) if comment.value in FMT_SKIP: prev_sibling = leaf.prev_sibling - if comment.value in leaf.prefix and prev_sibling is not None: - leaf.prefix = leaf.prefix.replace(comment.value, "") + # Need to properly format the leaf prefix to compare it to comment.value, + # which is also formatted + comments = list_comments(leaf.prefix, is_endmarker=False, preview=preview) + if comments and comment.value == comments[0].value and prev_sibling is not None: + leaf.prefix = "" siblings = [prev_sibling] while ( "\n" not in prev_sibling.prefix