summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-02-04 19:21:40 +0300
committervvvv <[email protected]>2025-02-04 21:32:52 +0300
commit8de4bd702eb90b0a0908781e3620c257484149bd (patch)
treecd60b09ece963e062fa04bcb8432c72a48d15fe4
parent3baeef8f8741d96e951eaf9b62176fb8e9589041 (diff)
YQL-19545 fixed indents for ??
commit_hash:ab832f6789d55200e094cc4fdfd75499e58d62c1
-rw-r--r--yql/essentials/sql/v1/format/sql_format.cpp10
-rw-r--r--yql/essentials/sql/v1/format/sql_format_ut.h8
2 files changed, 14 insertions, 4 deletions
diff --git a/yql/essentials/sql/v1/format/sql_format.cpp b/yql/essentials/sql/v1/format/sql_format.cpp
index 19619bf6e89..1240e073537 100644
--- a/yql/essentials/sql/v1/format/sql_format.cpp
+++ b/yql/essentials/sql/v1/format/sql_format.cpp
@@ -2671,10 +2671,11 @@ private:
}
void VisitNeqSubexpr(const TRule_neq_subexpr& msg) {
- VisitNeqSubexprImpl(msg, false);
+ bool pushedIndent = false;
+ VisitNeqSubexprImpl(msg, pushedIndent, true);
}
- void VisitNeqSubexprImpl(const TRule_neq_subexpr& msg, bool pushedIndent) {
+ void VisitNeqSubexprImpl(const TRule_neq_subexpr& msg, bool& pushedIndent, bool top) {
auto getExpr = [](const TRule_neq_subexpr::TBlock2& b) -> const TRule_bit_subexpr& { return b.GetRule_bit_subexpr2(); };
auto getOp = [](const TRule_neq_subexpr::TBlock2& b) -> const TRule_neq_subexpr::TBlock2::TBlock1& { return b.GetBlock1(); };
VisitBinaryOp(msg.GetRule_bit_subexpr1(), getOp, getExpr, msg.GetBlock2().begin(), msg.GetBlock2().end());
@@ -2706,9 +2707,10 @@ private:
}
}
- VisitNeqSubexprImpl(alt.GetRule_neq_subexpr2(), pushedIndent);
- if (pushedIndent) {
+ VisitNeqSubexprImpl(alt.GetRule_neq_subexpr2(), pushedIndent, false);
+ if (pushedIndent && top) {
PopCurrentIndent();
+ pushedIndent = false;
}
break;
diff --git a/yql/essentials/sql/v1/format/sql_format_ut.h b/yql/essentials/sql/v1/format/sql_format_ut.h
index b22bf1cb21c..b7fbc66f937 100644
--- a/yql/essentials/sql/v1/format/sql_format_ut.h
+++ b/yql/essentials/sql/v1/format/sql_format_ut.h
@@ -1632,6 +1632,14 @@ Y_UNIT_TEST(OperatorNewlines) {
"$x = 1\n\t>>|\n\t2;\n"},
{"$x = 1\n?? 2 ??\n3\n??\n4 +\n5\n*\n6 +\n7 ??\n8;",
"$x = 1 ??\n\t2 ??\n\t3\n\t??\n\t4\n\t+ 5\n\t*\n\t6\n\t+ 7 ??\n\t8;\n"},
+ {"select 1 ??\n2 ?? 3,\n4;",
+ "SELECT\n\t1 ??\n\t\t2 ?? 3,\n\t4\n;\n"},
+ {"select 1\n?? 2 ?? 3,\n4;",
+ "SELECT\n\t1 ??\n\t\t2 ?? 3,\n\t4\n;\n"},
+ {"select 1\n?? 2 ??\n3 ?? 4,\n5;",
+ "SELECT\n\t1 ??\n\t\t2 ??\n\t\t3 ?? 4,\n\t5\n;\n"},
+ {"select 1\n?? 2 ?? 3 ??\n4 ?? 5,\n6;",
+ "SELECT\n\t1 ??\n\t\t2 ?? 3 ??\n\t\t4 ?? 5,\n\t6\n;\n"},
};
TSetup setup;