From f6ccbd71c3f6264fd2c807a399dd64f5685f67d0 Mon Sep 17 00:00:00 2001 From: Sebastian Blunt Date: Sun, 19 Feb 2017 19:56:37 +0100 Subject: [PATCH] Add error_on_line_overflow option Makes it configurable whether to error if unable to get all lines within the max_width. --- src/config.rs | 1 + src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 508b569232be..892b90b117ed 100644 --- a/src/config.rs +++ b/src/config.rs @@ -333,6 +333,7 @@ create_config! { via the --file-lines option"; max_width: usize, 100, "Maximum width of each line"; ideal_width: usize, 80, "Ideal width of each line"; + error_on_line_overflow: bool, true, "Error if unable to get all lines within max_width"; tab_spaces: usize, 4, "Number of spaces per tab"; fn_call_width: usize, 60, "Maximum width of the args of a function call before falling back to vertical formatting"; diff --git a/src/lib.rs b/src/lib.rs index abe9a6e8554e..4fdc9ff8675d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -399,7 +399,7 @@ fn format_lines(text: &mut StringBuffer, name: &str, config: &Config, report: &m line_len -= b - lw; } // Check for any line width errors we couldn't correct. - if line_len > config.max_width { + if config.error_on_line_overflow && line_len > config.max_width { errors.push(FormattingError { line: cur_line, kind: ErrorKind::LineOverflow(line_len, config.max_width),