From 8b8a8efea13d1c97f856053af0a5c0e6a8a76354 Mon Sep 17 00:00:00 2001 From: Brian Forbis Date: Sat, 7 Oct 2017 19:57:40 -0400 Subject: [PATCH] THRIFT-4355 Fix javascript indentation of default values Client: js This closes #1388 --- compiler/cpp/src/thrift/generate/t_js_generator.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/cpp/src/thrift/generate/t_js_generator.cc b/compiler/cpp/src/thrift/generate/t_js_generator.cc index c146da71b46..f45ef5736af 100644 --- a/compiler/cpp/src/thrift/generate/t_js_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_js_generator.cc @@ -558,7 +558,7 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) { } else if (type->is_enum()) { out << value->get_integer(); } else if (type->is_struct() || type->is_xception()) { - out << "new " << js_type_namespace(type->get_program()) << type->get_name() << "({" << endl; + out << "new " << js_type_namespace(type->get_program()) << type->get_name() << "({"; indent_up(); const vector& fields = ((t_struct*)type)->get_members(); vector::const_iterator f_iter; @@ -576,12 +576,12 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) { } if (v_iter != val.begin()) out << ","; - out << render_const_value(g_type_string, v_iter->first); + out << endl << indent() << render_const_value(g_type_string, v_iter->first); out << " : "; out << render_const_value(field_type, v_iter->second); } - - out << "})"; + indent_down(); + out << endl << indent() << "})"; } else if (type->is_map()) { t_type* ktype = ((t_map*)type)->get_key_type(); @@ -600,9 +600,8 @@ string t_js_generator::render_const_value(t_type* type, t_const_value* value) { out << " : "; out << render_const_value(vtype, v_iter->second); } - indent_down(); - out << endl << "}"; + out << endl << indent() << "}"; } else if (type->is_list() || type->is_set()) { t_type* etype; if (type->is_list()) {