Skip to content

Commit

Permalink
Add line-continuation for multiline comparison nodes, fixes #10.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jun 13, 2024
1 parent 8ea1074 commit af825c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/runestone.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,11 @@ function indent_array_row(ctx::Context, node::Node)
return continue_all_newlines(ctx, node)
end

function indent_comparison(ctx::Context, node::Node)
@assert kind(node) === K"comparison"
return continue_all_newlines(ctx, node)
end

function insert_delete_mark_newlines(ctx::Context, node::Node)
if is_leaf(node)
return nothing
Expand Down Expand Up @@ -1152,6 +1157,8 @@ function insert_delete_mark_newlines(ctx::Context, node::Node)
return indent_array(ctx, node)
elseif kind(node) in KSet"row"
return indent_array_row(ctx, node)
elseif kind(node) === K"comparison"
return indent_comparison(ctx, node)
end
return nothing
end
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -433,5 +433,8 @@ end
@test format_string("[a,\n$(sp)b]") == "[a,\n b]"
@test format_string("[\n$(sp)a,\n$(sp)b\n$(sp)]") == "[\n a,\n b\n]"
@test format_string("[a b\n$(sp)c d]") == "[a b\n c d]"
# comparison
@test format_string("a == b ==\n$(sp)c") == "a == b ==\n c"
@test format_string("a <= b >=\n$(sp)c") == "a <= b >=\n c"
end
end

0 comments on commit af825c0

Please sign in to comment.