mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-06-21 23:19:24 -04:00
formatter: Make inline comments "transparent"
Adding an inline comment somewhere should not affect formatting below it. So, for inline comments, don't make the line type a comment, but instead reuse the current line type so that the comment becomes "transparent".
This commit is contained in:
parent
e16e723a81
commit
edc17dc2df
2 changed files with 4 additions and 2 deletions
|
@ -183,9 +183,11 @@ def format(data, tab_size=2, insert_space=True):
|
|||
current_line = f"// {current_line[2:]}"
|
||||
|
||||
inline_comment = not last_whitespace_contains_newline
|
||||
line_type = LineType.COMMENT
|
||||
newlines = 1
|
||||
if inline_comment:
|
||||
current_line = " " + current_line
|
||||
line_type = prev_line_type
|
||||
newlines = 0
|
||||
elif single_line_comment:
|
||||
if prev_line_type == LineType.BLOCK_CLOSE:
|
||||
|
@ -196,7 +198,7 @@ def format(data, tab_size=2, insert_space=True):
|
|||
current_line = "\n".join(
|
||||
[line.rstrip() for line in current_line.split("\n")]
|
||||
)
|
||||
commit_current_line(LineType.COMMENT, newlines_before=newlines)
|
||||
commit_current_line(line_type, newlines_before=newlines)
|
||||
|
||||
else: # pragma: no cover
|
||||
raise CompilerBugError()
|
||||
|
|
|
@ -59,7 +59,7 @@ Adw.MessageDialog {
|
|||
}
|
||||
|
||||
Adw.Breakpoint {
|
||||
condition ("width < 100")
|
||||
condition ("width < 100") // Another inline comment
|
||||
|
||||
setters {
|
||||
label2.label: _("Hello, world!");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue