X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/9edba85f71d50d12996ef7bda576426362016171..882d8795c6ff65c02f2657e596391748d1b6b7f5:/src/black/trans.py diff --git a/src/black/trans.py b/src/black/trans.py index a2bff7f..a3f6467 100644 --- a/src/black/trans.py +++ b/src/black/trans.py @@ -390,7 +390,19 @@ class StringMerger(StringTransformer, CustomSplitMapMixin): and is_valid_index(idx + 1) and LL[idx + 1].type == token.STRING ): - if not is_part_of_annotation(leaf): + # Let's check if the string group contains an inline comment + # If we have a comment inline, we don't merge the strings + contains_comment = False + i = idx + while is_valid_index(i): + if LL[i].type != token.STRING: + break + if line.comments_after(LL[i]): + contains_comment = True + break + i += 1 + + if not is_part_of_annotation(leaf) and not contains_comment: string_indices.append(idx) # Advance to the next non-STRING leaf.