Skip to content

Commit

Permalink
Added an extra space character in place of indentation on single-line…
Browse files Browse the repository at this point in the history
… output to make it look a little neater
  • Loading branch information
ShironekoBen committed Oct 27, 2024
1 parent f1c26b3 commit 26445dc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/code_dom/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,21 @@ def remove_redundant_whitespace(str):


# Write a C-style line with indentation, and any trailing whitespace removed
# If suppress_indent is set on the context, we emit a single space instead of the requested amount of indent
# (this is so that writing multiple things to the same line works sensibly)
def write_c_line(file, indent, context, text):
# We check for # here because if a line starts with a preprocessor directive we can't combine it with other lines
# safely
if context.suppress_newlines and (len(text) > 0) and (text[0] != '#'):
text = remove_redundant_whitespace(text.replace('\n', ' '))
if context.suppress_indent:
file.write(text.rstrip())
file.write(" " + text.rstrip())
else:
file.write("".ljust(indent * 4) + text.rstrip())
context.suppress_indent = True # We don't want indentation on following output
else:
if context.suppress_indent:
file.write(text.rstrip() + "\n")
file.write(" " + text.rstrip() + "\n")
else:
file.write("".ljust(indent * 4) + text.rstrip() + "\n")
context.suppress_indent = False

0 comments on commit 26445dc

Please sign in to comment.