From af825c00c0b6f554cb97ea9c51bbaef18b4fd598 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Thu, 13 Jun 2024 11:58:42 +0200 Subject: [PATCH] Add line-continuation for multiline comparison nodes, fixes #10. --- src/runestone.jl | 7 +++++++ test/runtests.jl | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/runestone.jl b/src/runestone.jl index 04597e3..4acb13d 100644 --- a/src/runestone.jl +++ b/src/runestone.jl @@ -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) 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 diff --git a/test/runtests.jl b/test/runtests.jl index 0135238..44b4983 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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