Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmakelang/format/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def format_comment_lines(node, stack_context, line_width):

items = markup.parse(inlines, config)
markup_lines = markup.format_items(config, max(10, line_width - 2), items)
return [prefix + (" " * len(line[:1])) + line for line in markup_lines]
return [prefix + (" " * len(line[:1]) if not line.startswith(prefix) else "") + line for line in markup_lines]


def normalize_line_endings(instr):
Expand Down
4 changes: 4 additions & 0 deletions cmakelang/format/testdata/test_in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ project(cmakelang_test)
# into a single comment
# on one line

######################
# This is some section
######################

# This comment should remain right before the command call.
# Furthermore, the command call should be formatted
# to a single line.
Expand Down
4 changes: 4 additions & 0 deletions cmakelang/format/testdata/test_out.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ project(cmakelang_test)

# This multiline-comment should be reflowed into a single comment on one line

###############################################################################
# This is some section
###############################################################################

# This comment should remain right before the command call. Furthermore, the
# command call should be formatted to a single line.
add_subdirectories(foo bar baz foo2 bar2 baz2)
Expand Down