From c819f67e1d2b40ff1c40d24549ee9d149b7b85fe Mon Sep 17 00:00:00 2001 From: Christopher Harrison Date: Tue, 20 Feb 2024 12:19:16 +0000 Subject: [PATCH 1/2] Nickel: Line break only before binding = in annotations Previously, a line break was prepended to _any_ `=` sign within an `annotated_assignment` scope. This was too liberal, if `=` signs appeared within annotations themselves. Resolves #680 --- topiary-cli/tests/samples/expected/nickel.ncl | 6 ++++++ topiary-cli/tests/samples/input/nickel.ncl | 6 ++++++ topiary-queries/queries/nickel.scm | 5 +++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/topiary-cli/tests/samples/expected/nickel.ncl b/topiary-cli/tests/samples/expected/nickel.ncl index 96fd3e84..f1a878e8 100644 --- a/topiary-cli/tests/samples/expected/nickel.ncl +++ b/topiary-cli/tests/samples/expected/nickel.ncl @@ -1,5 +1,11 @@ { regression_tests = [ + # Issue 680 + { + config + | { labels = { a = "a" } } + = {} + }, { a = [ b diff --git a/topiary-cli/tests/samples/input/nickel.ncl b/topiary-cli/tests/samples/input/nickel.ncl index e0e94768..5b6062f3 100644 --- a/topiary-cli/tests/samples/input/nickel.ncl +++ b/topiary-cli/tests/samples/input/nickel.ncl @@ -1,5 +1,11 @@ { regression_tests = [ + # Issue 680 + { + config + | { labels = { a = "a" } } + = {} + }, { a = [ b diff --git a/topiary-queries/queries/nickel.scm b/topiary-queries/queries/nickel.scm index 7e57da99..f4c0337c 100644 --- a/topiary-queries/queries/nickel.scm +++ b/topiary-queries/queries/nickel.scm @@ -287,8 +287,9 @@ ) ( - (#scope_id! "annotated_assignment") - "=" @prepend_spaced_scoped_softline + (annot) + . + "=" @prepend_spaced_softline ) ; Break a multi-line polymorphic type annotation after the type From 4ffce530cb8c2cee323822aa44d79ea196b9ce81 Mon Sep 17 00:00:00 2001 From: Christopher Harrison Date: Tue, 20 Feb 2024 12:24:05 +0000 Subject: [PATCH 2/2] Nickel: Remove `annotated_assigment` scope as now redundant --- topiary-queries/queries/nickel.scm | 9 --------- 1 file changed, 9 deletions(-) diff --git a/topiary-queries/queries/nickel.scm b/topiary-queries/queries/nickel.scm index f4c0337c..87c8840c 100644 --- a/topiary-queries/queries/nickel.scm +++ b/topiary-queries/queries/nickel.scm @@ -249,15 +249,6 @@ ;; Annotations -; We want the equals sign to be aligned with the annotations, if they -; coexist, so create a scope that covers them both. -( - (#scope_id! "annotated_assignment") - (annot) @prepend_begin_scope - . - "=" @append_end_scope -) - ; Start an indentation block from the start of the annotations to the ; end of the enclosing node (_