diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-01-15 01:06:10 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-01-15 01:06:10 +0100 |
| commit | cda7b552ac83c12a4f5b2e554bf714a0d66602cf (patch) | |
| tree | 1fe37bb3f0b7c9c9d43b2afc122cac4be1085894 /src | |
| parent | 9ece5cc4b8e74c9f50e34224b44471fdfc90c705 (diff) | |
odinfmt: fix comment being spaced in the beginning of the file.
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/printer.odin | 1 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/odin/printer/printer.odin b/src/odin/printer/printer.odin index a855384..cedf3a2 100644 --- a/src/odin/printer/printer.odin +++ b/src/odin/printer/printer.odin @@ -154,6 +154,7 @@ print :: proc(p: ^Printer, file: ^ast.File) -> string { build_disabled_lines_info(p) p.source_position.line = 1; + p.source_position.column = 1; p.document = move_line(p, file.pkg_token.pos); p.document = cons(p.document, cons_with_nopl(text(file.pkg_token.text), text(file.pkg_name))) diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index accfabb..7e0eb91 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -110,7 +110,7 @@ visit_comment :: proc(p: ^Printer, comment: tokenizer.Token, end_newline := true if comment.pos.line in p.disabled_lines { p.source_position = comment.pos return 1, empty() - } else if comment.pos.line == p.source_position.line { + } else if comment.pos.line == p.source_position.line && p.source_position.column != 1 { p.source_position = comment.pos return newlines_before_comment, cons_with_nopl(document, text(comment.text)) } else { @@ -124,7 +124,7 @@ visit_comment :: proc(p: ^Printer, comment: tokenizer.Token, end_newline := true p.source_position = comment.pos p.source_position.line += newlines return 1, empty() - } else if comment.pos.line == p.source_position.line { + } else if comment.pos.line == p.source_position.line && p.source_position.column != 1 { p.source_position = comment.pos p.source_position.line += newlines return newlines_before_comment+newlines, cons_with_opl(document, text(comment.text)) |