Skip to content
This repository
Browse code

Moved a hard-coded constant out into an option

    indent_ctor_init_leading  = 4        # virtual indent from the ':' for member
                                         # initializers. Default is 2.
                                         # (applies to the leading colon case)
this is needed for handling member initializer lists:

Thread::Thread()
    :   m_bStarted(false),
        m_log(/Thread)
{
    ....
}
  • Loading branch information...
commit a54dfa1aa36561c025ed2ba56861f19436fb50af 1 parent 9d3ab48
os12 authored April 01, 2012 bengardner committed April 06, 2012
2  src/indent.cpp
@@ -1041,7 +1041,7 @@ void indent_text(void)
1041 1041
             prev = chunk_get_prev(pc);
1042 1042
             if (chunk_is_newline(prev))
1043 1043
             {
1044  
-               frm.pse[frm.pse_tos].indent += 2;
  1044
+               frm.pse[frm.pse_tos].indent += cpd.settings[UO_indent_ctor_init_leading].n;
1045 1045
 
1046 1046
                if (cpd.settings[UO_indent_ctor_init].n > 0)
1047 1047
                {
3  src/options.cpp
@@ -527,6 +527,8 @@ void register_options(void)
527 527
                   "Whether the 'class' body is indented");
528 528
    unc_add_option("indent_class_colon", UO_indent_class_colon, AT_BOOL,
529 529
                   "Whether to indent the stuff after a leading class colon");
  530
+   unc_add_option("indent_ctor_init_leading", UO_indent_ctor_init_leading, AT_NUM,
  531
+                  "Virtual indent from the ':' for member initializers. Default is 2");
530 532
    unc_add_option("indent_ctor_init", UO_indent_ctor_init, AT_NUM,
531 533
                   "Additional indenting for constructor initializer list");
532 534
    unc_add_option("indent_else_if", UO_indent_else_if, AT_BOOL,
@@ -1759,6 +1761,7 @@ void set_option_defaults(void)
1759 1761
    cpd.settings[UO_newlines].le            = LE_AUTO;
1760 1762
    cpd.settings[UO_input_tab_size].n       = 8;
1761 1763
    cpd.settings[UO_output_tab_size].n      = 8;
  1764
+   cpd.settings[UO_indent_ctor_init_leading].n = 2;
1762 1765
    cpd.settings[UO_indent_columns].n       = 8;
1763 1766
    cpd.settings[UO_indent_with_tabs].n     = 1;
1764 1767
    cpd.settings[UO_indent_label].n         = 1;
1  src/options.h
@@ -164,6 +164,7 @@ enum uncrustify_options
164 164
    UO_indent_class,                         // indent stuff inside class braces
165 165
    UO_indent_class_colon,                   // indent stuff after a class colon
166 166
 
  167
+   UO_indent_ctor_init_leading,             // virtual indent from the ':' for member initializers. Default is 2. (applies to the leading colon case)
167 168
    UO_indent_ctor_init,                     // additional indenting for ctor initializer lists
168 169
 
169 170
    UO_indent_member,                        // indent lines broken at a member '.' or '->'
2  src/space.cpp
@@ -1031,6 +1031,8 @@ static argval_t do_space(chunk_t *first, chunk_t *second, int& min_sp, bool comp
1031 1031
    if ((cpd.settings[UO_sp_after_class_colon].a != AV_IGNORE) &&
1032 1032
        (first->type == CT_CLASS_COLON))
1033 1033
    {
  1034
+      min_sp = cpd.settings[UO_indent_ctor_init_leading].n - 1; // default indent is 1 space
  1035
+
1034 1036
       log_rule("sp_after_class_colon");
1035 1037
       return(cpd.settings[UO_sp_after_class_colon].a);
1036 1038
    }

0 notes on commit a54dfa1

Please sign in to comment.
Something went wrong with that request. Please try again.