Repository: domluna/JuliaFormatter.jl
Pull request #310 (2020-10-01 01:48:37)

Inner styles for Blue and YAS styles
This allows all styles to be interleaved which allows dispatch on the most appropriate style


Patch:
diff --git a/Project.toml b/Project.toml
index aea0aacc..d3ee445a 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
 name = "JuliaFormatter"
 uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
 authors = ["Dominique Luna <dluna132@gmail.com>"]
-version = "0.10.0"
+version = "0.10.1"
 
 [deps]
 CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
diff --git a/src/styles/blue/nest.jl b/src/styles/blue/nest.jl
index 6ccc6b70..837baa4e 100644
--- a/src/styles/blue/nest.jl
+++ b/src/styles/blue/nest.jl
@@ -1,4 +1,5 @@
 function n_tupleh!(bs::BlueStyle, fst::FST, s::State)
+    style = getstyle(bs)
     line_margin = s.line_offset + length(fst) + fst.extra_margin
     lidx = findlast(n -> n.typ === PLACEHOLDER, fst.nodes)
     fidx = findfirst(n -> n.typ === PLACEHOLDER, fst.nodes)
@@ -41,22 +42,22 @@ function n_tupleh!(bs::BlueStyle, fst::FST, s::State)
                     n.val = ","
                     n.len = 1
                 end
-                nest!(bs, n, s)
+                nest!(style, n, s)
             elseif n.typ === TRAILINGSEMICOLON
                 n.val = ";"
                 n.len = 1
-                nest!(bs, n, s)
+                nest!(style, n, s)
             elseif n.typ === INVERSETRAILINGSEMICOLON
                 n.val = ""
                 n.len = 0
-                nest!(bs, n, s)
+                nest!(style, n, s)
             elseif opener && (i == 1 || i == length(fst.nodes))
-                nest!(bs, n, s)
+                nest!(style, n, s)
             else
                 diff = fst.indent - fst[i].indent
                 add_indent!(n, s, diff)
                 n.extra_margin = 1
-                nest!(bs, n, s)
+                nest!(style, n, s)
             end
         end
 
@@ -67,7 +68,7 @@ function n_tupleh!(bs::BlueStyle, fst::FST, s::State)
     else
         extra_margin = fst.extra_margin
         opener && (extra_margin += 1)
-        nest!(bs, fst.nodes, s, fst.indent, extra_margin = extra_margin)
+        nest!(style, fst.nodes, s, fst.indent, extra_margin = extra_margin)
     end
 end
 @inline n_call!(bs::BlueStyle, fst::FST, s::State) = n_tupleh!(bs, fst, s)
@@ -82,11 +83,16 @@ end
 # @inline n_vcat!(bs::BlueStyle, fst::FST, s::State) = n_tupleh!(bs, fst, s)
 
 function n_conditionalopcall!(bs::BlueStyle, fst::FST, s::State)
+    style = getstyle(bs)
     if fst[end].typ === CSTParser.ConditionalOpCall
         conditional_to_if_block!(fst, s)
-        nest!(bs, fst, s)
+        nest!(style, fst, s)
     else
-        n_conditionalopcall!(DefaultStyle(bs), fst, s)
+        n_conditionalopcall!(DefaultStyle(style), fst, s)
     end
     return
 end
+
+function n_binaryopcall!(bs::BlueStyle, fst::FST, s::State)
+    n_binaryopcall!(YASStyle(bs), fst, s)
+end
diff --git a/src/styles/blue/pretty.jl b/src/styles/blue/pretty.jl
index 68fd2ca4..8829d0cd 100644
--- a/src/styles/blue/pretty.jl
+++ b/src/styles/blue/pretty.jl
@@ -19,8 +19,12 @@ Configurable options with different defaults to [`DefaultStyle`](@ref) are:
 - `whitespace_in_kwargs` = false
 - `annotate_untyped_fields_with_any` = false
 """
-struct BlueStyle <: AbstractStyle end
-@inline getstyle(s::BlueStyle) = s
+struct BlueStyle <: AbstractStyle
+    innerstyle::Union{Nothing,AbstractStyle}
+end
+BlueStyle() = BlueStyle(nothing)
+
+@inline getstyle(s::BlueStyle) = s.innerstyle === nothing ? s : s.innerstyle
 
 function options(style::BlueStyle)
     return (;
@@ -42,7 +46,8 @@ function nestable(::BlueStyle, cst::CSTParser.EXPR)
     return nestable(DefaultStyle(), cst)
 end
 
-function p_do(style::BlueStyle, cst::CSTParser.EXPR, s::State)
+function p_do(bs::BlueStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(bs)
     t = FST(cst, nspaces(s))
     add_node!(t, pretty(style, cst[1], s), s)
     add_node!(t, Whitespace(1), s)
@@ -87,7 +92,8 @@ function separate_kwargs_with_semicolon!(fst::FST)
 end
 
 function p_call(bs::BlueStyle, cst::CSTParser.EXPR, s::State)
-    t = p_call(DefaultStyle(bs), cst, s)
+    style = getstyle(bs)
+    t = p_call(DefaultStyle(style), cst, s)
     if !parent_is(cst, is_function_or_macro_def)
         separate_kwargs_with_semicolon!(t)
     end
@@ -197,12 +203,13 @@ function p_binaryopcall(
 end
 
 function p_return(bs::BlueStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(bs)
     t = FST(cst, nspaces(s))
-    add_node!(t, pretty(bs, cst[1], s), s)
+    add_node!(t, pretty(style, cst[1], s), s)
     if cst[2].fullspan != 0
         for a in cst.args[2:end]
             add_node!(t, Whitespace(1), s)
-            add_node!(t, pretty(bs, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
         end
     elseif cst[2].kind === Tokens.NOTHING
         add_node!(t, Whitespace(1), s)
diff --git a/src/styles/default/nest.jl b/src/styles/default/nest.jl
index 24cce2a4..e0488ca6 100644
--- a/src/styles/default/nest.jl
+++ b/src/styles/default/nest.jl
@@ -79,8 +79,10 @@ function nest!(ds::DefaultStyle, fst::FST, s::State)
            fst.ref !== nothing &&
            CSTParser.defines_function(fst.ref[])
             short_to_long_function_def!(fst, s)
+            nest!(style, fst, s)
+        else
+            n_binaryopcall!(style, fst, s)
         end
-        n_binaryopcall!(style, fst, s)
     elseif fst.typ === CSTParser.Curly
         n_curly!(style, fst, s)
     elseif fst.typ === CSTParser.Call
diff --git a/src/styles/yas/nest.jl b/src/styles/yas/nest.jl
index 4a83b2d7..0968fd7f 100644
--- a/src/styles/yas/nest.jl
+++ b/src/styles/yas/nest.jl
@@ -1,4 +1,5 @@
 function n_call!(ys::YASStyle, fst::FST, s::State)
+    style = getstyle(ys)
     fst.indent = s.line_offset + sum(length.(fst[1:2]))
 
     for (i, n) in enumerate(fst.nodes)
@@ -6,20 +7,20 @@ function n_call!(ys::YASStyle, fst::FST, s::State)
             s.line_offset = fst.indent
         elseif n.typ === PLACEHOLDER
             si = findnext(n -> n.typ === PLACEHOLDER, fst.nodes, i + 1)
-            nest_if_over_margin!(ys, fst, s, i; stop_idx = si)
+            nest_if_over_margin!(style, fst, s, i; stop_idx = si)
         elseif n.typ === TRAILINGSEMICOLON
             n.val = ""
             n.len = 0
-            nest!(ys, n, s)
+            nest!(style, n, s)
         elseif is_gen(n)
             n.indent = fst.indent
             n.extra_margin = 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         else
             diff = fst.indent - fst[i].indent
             add_indent!(n, s, diff)
             n.extra_margin = 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         end
     end
 end
@@ -29,6 +30,7 @@ end
 @inline n_typedcomprehension!(ys::YASStyle, fst::FST, s::State) = n_call!(ys, fst, s)
 
 function n_tupleh!(ys::YASStyle, fst::FST, s::State)
+    style = getstyle(ys)
     fst.indent = s.line_offset
     length(fst.nodes) > 0 && is_opener(fst[1]) && (fst.indent += 1)
 
@@ -37,20 +39,20 @@ function n_tupleh!(ys::YASStyle, fst::FST, s::State)
             s.line_offset = fst.indent
         elseif n.typ === PLACEHOLDER
             si = findnext(n -> n.typ === PLACEHOLDER, fst.nodes, i + 1)
-            nest_if_over_margin!(ys, fst, s, i; stop_idx = si)
+            nest_if_over_margin!(style, fst, s, i; stop_idx = si)
         elseif n.typ === TRAILINGSEMICOLON
             n.val = ""
             n.len = 0
-            nest!(ys, n, s)
+            nest!(style, n, s)
         elseif is_gen(n)
             n.indent = fst.indent
             n.extra_margin = 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         else
             diff = fst.indent - fst[i].indent
             add_indent!(n, s, diff)
             n.extra_margin = 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         end
     end
 end
@@ -61,6 +63,7 @@ end
 @inline n_comprehension!(ys::YASStyle, fst::FST, s::State) = n_tupleh!(ys, fst, s)
 
 function n_generator!(ys::YASStyle, fst::FST, s::State)
+    style = getstyle(ys)
     diff = s.line_offset - fst[1].indent
 
     # if the first argument is not a leaf
@@ -73,14 +76,14 @@ function n_generator!(ys::YASStyle, fst::FST, s::State)
             s.line_offset = fst.indent
         elseif n.typ === PLACEHOLDER
             si = findnext(n -> n.typ === PLACEHOLDER, fst.nodes, i + 1)
-            nest_if_over_margin!(ys, fst, s, i; stop_idx = si)
+            nest_if_over_margin!(style, fst, s, i; stop_idx = si)
         elseif is_gen(n)
             n.indent = fst.indent
             n.extra_margin = 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         else
             n.extra_margin = 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         end
     end
 end
@@ -88,6 +91,7 @@ end
 @inline n_flatten!(ys::YASStyle, fst::FST, s::State) = n_generator!(ys, fst, s)
 
 function n_whereopcall!(ys::YASStyle, fst::FST, s::State)
+    style = getstyle(ys)
     fst.indent = s.line_offset
     # after "A where "
     Blen = sum(length.(fst[2:end]))
@@ -98,20 +102,21 @@ function n_whereopcall!(ys::YASStyle, fst::FST, s::State)
             s.line_offset = fst.indent
         elseif n.typ === PLACEHOLDER
             si = findnext(n -> n.typ === PLACEHOLDER, fst.nodes, i + 1)
-            nest_if_over_margin!(ys, fst, s, i; stop_idx = si)
+            nest_if_over_margin!(style, fst, s, i; stop_idx = si)
         elseif is_opener(n) && n.val == "{"
             fst.indent = s.line_offset + 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         elseif i == 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         else
             n.extra_margin = 1
-            nest!(ys, n, s)
+            nest!(style, n, s)
         end
     end
 end
 
 function n_using!(ys::YASStyle, fst::FST, s::State)
+    style = getstyle(ys)
     idx = findfirst(n -> n.val == ":", fst.nodes)
     fst.indent = s.line_offset
     if idx === nothing
@@ -122,11 +127,11 @@ function n_using!(ys::YASStyle, fst::FST, s::State)
     for (i, n) in enumerate(fst.nodes)
         if n.typ === PLACEHOLDER
             si = findnext(n -> n.typ === PLACEHOLDER, fst.nodes, i + 1)
-            nest_if_over_margin!(ys, fst, s, i; stop_idx = si)
+            nest_if_over_margin!(style, fst, s, i; stop_idx = si)
         elseif n.typ === NEWLINE
             s.line_offset = fst.indent
         else
-            nest!(ys, n, s)
+            nest!(style, n, s)
         end
     end
 end
@@ -139,13 +144,13 @@ n_comparison!(ys::YASStyle, fst::FST, s::State) =
     n_block!(DefaultStyle(ys), fst, s, indent = s.line_offset)
 
 function n_binaryopcall!(ys::YASStyle, fst::FST, s::State)
-    idx = findfirst(n -> n.typ === PLACEHOLDER, fst.nodes)
-
-    if idx !== nothing
-        n_binaryopcall!(DefaultStyle(ys), fst, s)
+    style = getstyle(ys)
+    if findfirst(n -> n.typ === PLACEHOLDER, fst.nodes) !== nothing
+        n_binaryopcall!(DefaultStyle(style), fst, s)
         return
     end
 
+    start_line_offset = s.line_offset
     walk(increment_line_offset!, fst.nodes[1:end-1], s, fst.indent)
-    nest!(ys, fst[end], s)
+    nest!(style, fst[end], s)
 end
diff --git a/src/styles/yas/pretty.jl b/src/styles/yas/pretty.jl
index bffb5fb3..7de45949 100644
--- a/src/styles/yas/pretty.jl
+++ b/src/styles/yas/pretty.jl
@@ -14,8 +14,11 @@ Configurable options with different defaults to [`DefaultStyle`](@ref) are:
 - `always_use_return` = true
 - `whitespace_in_kwargs` = false
 """
-struct YASStyle <: AbstractStyle end
-@inline getstyle(s::YASStyle) = s
+struct YASStyle <: AbstractStyle
+    innerstyle::Union{Nothing,AbstractStyle}
+end
+YASStyle() = YASStyle(nothing)
+@inline getstyle(s::YASStyle) = s.innerstyle === nothing ? s : s.innerstyle
 
 function options(style::YASStyle)
     return (;
@@ -37,19 +40,20 @@ function nestable(::YASStyle, cst::CSTParser.EXPR)
 end
 
 function p_import(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
-    add_node!(t, pretty(ys, cst[1], s), s)
+    add_node!(t, pretty(style, cst[1], s), s)
     add_node!(t, Whitespace(1), s)
 
     for (i, a) in enumerate(cst.args[2:end])
         if CSTParser.is_comma(a)
-            add_node!(t, pretty(ys, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
             add_node!(t, Placeholder(1), s)
         elseif CSTParser.is_colon(a)
-            add_node!(t, pretty(ys, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
             add_node!(t, Whitespace(1), s)
         else
-            add_node!(t, pretty(ys, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
         end
     end
     t
@@ -58,9 +62,10 @@ end
 @inline p_export(ys::YASStyle, cst::CSTParser.EXPR, s::State) = p_import(ys, cst, s)
 
 function p_curly(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
     for (i, a) in enumerate(cst)
-        n = pretty(ys, a, s)
+        n = pretty(style, a, s)
         if CSTParser.is_comma(a) && i == length(cst) - 1
             continue
         elseif CSTParser.is_comma(a) && i < length(cst) && !is_punc(cst[i+1])
@@ -75,10 +80,11 @@ end
 @inline p_braces(ys::YASStyle, cst::CSTParser.EXPR, s::State) = p_curly(ys, cst, s)
 
 function p_tupleh(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
     for (i, a) in enumerate(cst)
         if CSTParser.is_comma(a) && i + 1 == length(cst)
-            n = pretty(ys, a, s)
+            n = pretty(style, a, s)
             if n_args(cst) == 1
                 add_node!(t, n, s, join_lines = true)
             elseif !is_closer(cst[i+1])
@@ -86,21 +92,22 @@ function p_tupleh(ys::YASStyle, cst::CSTParser.EXPR, s::State)
                 add_node!(t, Placeholder(1), s)
             end
         elseif CSTParser.is_comma(a) && i < length(cst) && !is_punc(cst[i+1])
-            add_node!(t, pretty(ys, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
             add_node!(t, Placeholder(1), s)
         elseif a.typ === CSTParser.BinaryOpCall && a[2].kind === Tokens.EQ
-            add_node!(t, p_kw(ys, a, s), s, join_lines = true)
+            add_node!(t, p_kw(style, a, s), s, join_lines = true)
         else
-            add_node!(t, pretty(ys, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
         end
     end
     t
 end
 
 function p_tupleh(ys::YASStyle, nodes::Vector{CSTParser.EXPR}, s::State)
+    style = getstyle(ys)
     t = FST(CSTParser.TupleH, nspaces(s))
     for (i, a) in enumerate(nodes)
-        n = pretty(ys, a, s)
+        n = pretty(style, a, s)
         if CSTParser.is_comma(a) && i + 1 == length(nodes)
             if n_args(nodes) == 1
                 add_node!(t, n, s, join_lines = true)
@@ -126,7 +133,8 @@ function p_invisbrackets(
     nonest = false,
     nospace = false,
 )
-    t = p_invisbrackets(DefaultStyle(ys), cst, s, nonest = nonest, nospace = nospace)
+    style = getstyle(ys)
+    t = p_invisbrackets(DefaultStyle(style), cst, s, nonest = nonest, nospace = nospace)
     for (i, n) in enumerate(t.nodes)
         if n.typ === PLACEHOLDER
             t[i] = Whitespace(length(n))
@@ -136,9 +144,10 @@ function p_invisbrackets(
 end
 
 function p_call(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
     for (i, a) in enumerate(cst)
-        n = pretty(ys, a, s)
+        n = pretty(style, a, s)
         if CSTParser.is_comma(a) && i + 1 == length(cst)
             continue
         elseif CSTParser.is_comma(a) && i < length(cst) && !is_punc(cst[i+1])
@@ -153,55 +162,59 @@ end
 @inline p_vect(ys::YASStyle, cst::CSTParser.EXPR, s::State) = p_call(ys, cst, s)
 
 function p_ref(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
     nospace = !s.opts.whitespace_ops_in_indices
 
     for (i, a) in enumerate(cst)
         if CSTParser.is_comma(a) && i < length(cst) && !is_punc(cst[i+1])
-            add_node!(t, pretty(ys, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
             add_node!(t, Placeholder(1), s)
         elseif a.typ === CSTParser.BinaryOpCall ||
                a.typ === CSTParser.InvisBrackets ||
                a.typ === CSTParser.ChainOpCall ||
                a.typ === CSTParser.Comparison
-            n = pretty(ys, a, s, nonest = true, nospace = nospace)
+            n = pretty(style, a, s, nonest = true, nospace = nospace)
             add_node!(t, n, s, join_lines = true)
         else
-            add_node!(t, pretty(ys, a, s), s, join_lines = true)
+            add_node!(t, pretty(style, a, s), s, join_lines = true)
         end
     end
     t
 end
 
 function p_comprehension(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
 
     if is_block(cst[2]) || (cst[2].typ === CSTParser.Generator && is_block(cst[2][1]))
         t.nest_behavior = AlwaysNest
     end
 
-    add_node!(t, pretty(ys, cst[1], s), s, join_lines = true)
-    add_node!(t, pretty(ys, cst[2], s), s, join_lines = true)
-    add_node!(t, pretty(ys, cst[3], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[1], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[2], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[3], s), s, join_lines = true)
     t
 end
 
 function p_typedcomprehension(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
 
     if is_block(cst[3]) || (cst[3].typ === CSTParser.Generator && is_block(cst[3][1]))
         t.nest_behavior = AlwaysNest
     end
 
-    add_node!(t, pretty(ys, cst[1], s), s, join_lines = true)
-    add_node!(t, pretty(ys, cst[2], s), s, join_lines = true)
-    add_node!(t, pretty(ys, cst[3], s), s, join_lines = true)
-    add_node!(t, pretty(ys, cst[4], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[1], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[2], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[3], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[4], s), s, join_lines = true)
     t
 end
 
 function p_macrocall(ys::YASStyle, cst::CSTParser.EXPR, s::State)
-    fst = p_macrocall(DefaultStyle(ys), cst, s)
+    style = getstyle(ys)
+    fst = p_macrocall(DefaultStyle(style), cst, s)
     fst.typ == CSTParser.MacroCall || return fst
     is_closer(cst.args[end]) || return fst
 
@@ -216,9 +229,11 @@ function p_macrocall(ys::YASStyle, cst::CSTParser.EXPR, s::State)
 end
 
 function p_parameters(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
+
     for (i, a) in enumerate(cst)
-        n = pretty(ys, a, s)
+        n = pretty(style, a, s)
         if i == length(cst) && CSTParser.is_comma(a)
             # do nothing
         elseif CSTParser.is_comma(a) && i < length(cst) && !is_punc(cst[i+1])
@@ -232,10 +247,12 @@ function p_parameters(ys::YASStyle, cst::CSTParser.EXPR, s::State)
 end
 
 function p_whereopcall(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
-    add_node!(t, pretty(ys, cst[1], s), s)
+
+    add_node!(t, pretty(style, cst[1], s), s)
     add_node!(t, Whitespace(1), s)
-    add_node!(t, pretty(ys, cst[2], s), s, join_lines = true)
+    add_node!(t, pretty(style, cst[2], s), s, join_lines = true)
     add_node!(t, Whitespace(1), s)
 
     add_braces =
@@ -251,8 +268,8 @@ function p_whereopcall(ys::YASStyle, cst::CSTParser.EXPR, s::State)
 
     for (i, a) in enumerate(cst.args[3:end])
         n =
-            a.typ === CSTParser.BinaryOpCall ? pretty(ys, a, s, nospace = true) :
-            pretty(ys, a, s)
+            a.typ === CSTParser.BinaryOpCall ? pretty(style, a, s, nospace = true) :
+            pretty(style, a, s)
 
         if CSTParser.is_comma(a) && i + 2 == length(cst) - 1
             continue
@@ -272,10 +289,11 @@ function p_whereopcall(ys::YASStyle, cst::CSTParser.EXPR, s::State)
 end
 
 function p_generator(ys::YASStyle, cst::CSTParser.EXPR, s::State)
+    style = getstyle(ys)
     t = FST(cst, nspaces(s))
 
     for (i, a) in enumerate(cst)
-        n = pretty(ys, a, s)
+        n = pretty(style, a, s)
         if a.typ === CSTParser.KEYWORD
             incomp = parent_is(
                 a,
@@ -300,7 +318,7 @@ function p_generator(ys::YASStyle, cst::CSTParser.EXPR, s::State)
             end
 
             if !is_gen(cst.args[i+1])
-                tup = p_tupleh(ys, cst.args[i+1:length(cst)], s)
+                tup = p_tupleh(style, cst.args[i+1:length(cst)], s)
                 add_node!(t, tup, s, join_lines = true)
                 return t
             end


Test patch:
diff --git a/test/blue_style.jl b/test/blue_style.jl
index a1a26b6a..5afe7b9f 100644
--- a/test/blue_style.jl
+++ b/test/blue_style.jl
@@ -165,6 +165,16 @@
         )
         """
         @test bluefmt(str_, 4, 92) == str
+
+        str_ = """
+        df[:, :some_column] = [some_big_function_name(blahhh) for (fooooo, blahhh) in my_long_list_of_vars]
+        """
+        str = """
+        df[:, :some_column] = [
+            some_big_function_name(blahhh) for (fooooo, blahhh) in my_long_list_of_vars
+        ]
+        """
+        @test bluefmt(str_, 4, 92) == str
     end
 
     @testset "do not prepend return in `do` blocks" begin