Support different tabbing of function args

(Although, frankly anything other than visual is deeply wrong).
This commit is contained in:
Nick Cameron 2015-09-01 17:22:00 +12:00
parent 89cda8d43a
commit 0413c47a09
3 changed files with 13 additions and 2 deletions

View File

@ -90,6 +90,7 @@ create_config! {
fn_return_indent: ReturnIndent,
fn_args_paren_newline: bool,
fn_args_layout: Density,
fn_arg_indent: BlockIndentStyle,
struct_trailing_comma: SeparatorTactic,
struct_lit_trailing_comma: SeparatorTactic,
struct_lit_style: StructLitStyle,
@ -115,6 +116,7 @@ impl Default for Config {
fn_return_indent: ReturnIndent::WithArgs,
fn_args_paren_newline: true,
fn_args_layout: Density::Tall,
fn_arg_indent: BlockIndentStyle::Visual,
struct_trailing_comma: SeparatorTactic::Vertical,
struct_lit_trailing_comma: SeparatorTactic::Vertical,
struct_lit_style: StructLitStyle::BlockIndent,

View File

@ -18,7 +18,7 @@ use expr::rewrite_assign_rhs;
use comment::FindUncommented;
use visitor::FmtVisitor;
use rewrite::Rewrite;
use config::Config;
use config::{Config, BlockIndentStyle};
use syntax::{ast, abi};
use syntax::codemap::{self, Span, BytePos};
@ -237,6 +237,7 @@ impl<'a> FmtVisitor<'a> {
explicit_self,
one_line_budget,
multi_line_budget,
indent,
arg_indent,
args_span));
result.push(')');
@ -293,6 +294,7 @@ impl<'a> FmtVisitor<'a> {
explicit_self: Option<&ast::ExplicitSelf>,
one_line_budget: usize,
multi_line_budget: usize,
indent: usize,
arg_indent: usize,
span: Span)
-> String {
@ -341,11 +343,17 @@ impl<'a> FmtVisitor<'a> {
item.item = arg;
}
let indent = match self.config.fn_arg_indent {
BlockIndentStyle::Inherit => indent,
BlockIndentStyle::Tabbed => indent + self.config.tab_spaces,
BlockIndentStyle::Visual => arg_indent,
};
let fmt = ListFormatting {
tactic: self.config.fn_args_layout.to_list_tactic(),
separator: ",",
trailing_separator: SeparatorTactic::Never,
indent: arg_indent,
indent: indent,
h_width: one_line_budget,
v_width: multi_line_budget,
ends_with_newline: false,

View File

@ -7,6 +7,7 @@ fn_brace_style = "SameLineWhere"
fn_return_indent = "WithArgs"
fn_args_paren_newline = true
fn_args_layout = "Tall"
fn_arg_indent = "Visual"
struct_trailing_comma = "Vertical"
struct_lit_trailing_comma = "Vertical"
struct_lit_style = "BlockIndent"