Skip to content

Commit

Permalink
Merge pull request #1269 from Jaseci-Labs/comment_space
Browse files Browse the repository at this point in the history
Fix: Comment placement with LBrace
  • Loading branch information
marsninja authored Sep 11, 2024
2 parents a809679 + ab0d178 commit 9b722a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 10 additions & 0 deletions jac/jaclang/compiler/passes/tool/jac_formatter_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,16 @@ def exit_sub_node_list(self, node: ast.SubNodeList) -> None:
if prev_token and isinstance(prev_token, ast.Ability):
self.emit(node, f"{stmt.gen.jac}")
else:
token_before = self.token_before(stmt)
if (
token_before is not None
and isinstance(token_before, ast.Token)
and token_before.name == Tok.LBRACE
and stmt.loc.first_line - token_before.loc.last_line > 1
):
self.indent_level -= 1
self.emit_ln(node, "")
self.indent_level += 1
self.emit(node, stmt.gen.jac)
self.indent_level -= 1
self.emit_ln(stmt, "")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import:py math;

glob RAD = 5;

glob DIA = 10;

# this comment is for walker

walker decorator_walk {
can hash(func: Any) {
can inner(a: Any) {
Expand Down Expand Up @@ -39,14 +41,14 @@ walker decorator_walk {
# Entry point for the walker

can start with entry {

# Apply decorators to greeter
decorated_greeter = hash(exclaim(tilde(greeter)));

# Call the decorated greeter function
decorated_greeter("World");

# this is another comment

}
}

Expand Down

0 comments on commit 9b722a6

Please sign in to comment.