Browse Source

Add line-continuation for multiline comparison nodes, fixes #10.

pull/19/head
Fredrik Ekre 2 years ago
parent
commit
af825c00c0
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 7
      src/runestone.jl
  2. 3
      test/runtests.jl

7
src/runestone.jl

@ -1107,6 +1107,11 @@ function indent_array_row(ctx::Context, node::Node) @@ -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
@ -1152,6 +1157,8 @@ function insert_delete_mark_newlines(ctx::Context, node::Node) @@ -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
test/runtests.jl

@ -433,5 +433,8 @@ end @@ -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

Loading…
Cancel
Save