Browse Source

Fix continuation-indent in cartesian iterator heads

pull/30/head
Fredrik Ekre 1 year ago
parent
commit
7ab66e5fd1
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

@ -2528,6 +2528,11 @@ function indent_ternary(ctx::Context, node::Node)
return continue_all_newlines(ctx, node) return continue_all_newlines(ctx, node)
end end
function indent_iterator(ctx::Context, node::Node)
@assert kind(node) === K"cartesian_iterator"
return continue_all_newlines(ctx, node)
end
function indent_assignment(ctx::Context, node::Node) function indent_assignment(ctx::Context, node::Node)
kids = verified_kids(node) kids = verified_kids(node)
# Also catches for loop specifications (but at this point we have normalized `=` and `∈` # Also catches for loop specifications (but at this point we have normalized `=` and `∈`
@ -2728,6 +2733,8 @@ function insert_delete_mark_newlines(ctx::Context, node::Node)
return indent_parameters(ctx, node) return indent_parameters(ctx, node)
elseif kind(node) === K"?" elseif kind(node) === K"?"
return indent_ternary(ctx, node) return indent_ternary(ctx, node)
elseif kind(node) === K"cartesian_iterator"
return indent_iterator(ctx, node)
elseif kind(node) === K"try" elseif kind(node) === K"try"
return indent_try(ctx, node) return indent_try(ctx, node)
elseif kind(node) === K"quote" elseif kind(node) === K"quote"

3
test/runtests.jl

@ -759,6 +759,9 @@ end
# implicit tuple # implicit tuple
@test format_string("a,\n$(sp)b") == "a,\n b" @test format_string("a,\n$(sp)b") == "a,\n b"
@test format_string("a,\n$(sp)b + \nb") == "a,\n b +\n b" @test format_string("a,\n$(sp)b + \nb") == "a,\n b +\n b"
# K"cartesian_iterator"
@test format_string("for i in I,\n$(sp)j in J\n# body\nend") ==
"for i in I,\n j in J\n # body\nend"
end end
end end

Loading…
Cancel
Save