Option to disable line breaking in comments
Set to false by default for now, since we are having a lot of problems with comments. We should set to true once we have a better algorithm.
This commit is contained in:
parent
1c0934772c
commit
b7d61254a7
@ -81,7 +81,7 @@ pub fn rewrite_comment(orig: &str,
|
||||
result.push_str(line_start);
|
||||
}
|
||||
|
||||
if line.len() > max_chars {
|
||||
if config.wrap_comments && line.len() > max_chars {
|
||||
let rewrite = try_opt!(rewrite_string(line, &fmt));
|
||||
result.push_str(&rewrite);
|
||||
} else {
|
||||
@ -439,7 +439,8 @@ mod test {
|
||||
#[test]
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
fn format_comments() {
|
||||
let config = Default::default();
|
||||
let mut config: ::config::Config = Default::default();
|
||||
config.wrap_comments = true;
|
||||
assert_eq!("/* test */", rewrite_comment(" //test", true, 100, Indent::new(0, 100),
|
||||
&config).unwrap());
|
||||
assert_eq!("// comment\n// on a", rewrite_comment("// comment on a", false, 10,
|
||||
|
@ -294,11 +294,11 @@ create_config! {
|
||||
report_fixme: ReportTactic, ReportTactic::Never,
|
||||
"Report all, none or unnumbered occurrences of FIXME in source file comments";
|
||||
chain_base_indent: BlockIndentStyle, BlockIndentStyle::Visual, "Indent on chain base";
|
||||
// Alphabetically, case sensitive.
|
||||
reorder_imports: bool, false, "Reorder import statements alphabetically";
|
||||
single_line_if_else: bool, false, "Put else on same line as closing brace for if statements";
|
||||
format_strings: bool, true, "Format string literals, or leave as is";
|
||||
chains_overflow_last: bool, true, "Allow last call in method chain to break the line";
|
||||
take_source_hints: bool, true, "Retain some formatting characteristics from the source code";
|
||||
hard_tabs: bool, false, "Use tab characters for indentation, spaces for alignment";
|
||||
wrap_comments: bool, false, "Break comments to fit on the line";
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test attributes and doc comments are preserved.
|
||||
|
||||
/// Blah blah blah.
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
//! Doc comment
|
||||
fn test() {
|
||||
// comment
|
||||
|
@ -1,2 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
/// This is a long line that angers rustfmt. Rustfmt shall deal with it swiftly and justly.
|
||||
pub mod foo {}
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
//! This is a long line that angers rustfmt. Rustfmt shall deal with it swiftly and justly.
|
||||
|
||||
pub mod foo {}
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Enums test
|
||||
|
||||
#[atrr]
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test expressions
|
||||
|
||||
fn foo() -> bool {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-hard_tabs: true
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test of lots of random stuff.
|
||||
// FIXME split this into multiple, self-contained tests.
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Struct literal expressions.
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
|
||||
// Struct literal expressions.
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
|
||||
// Struct literal expressions.
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
/// A Doc comment
|
||||
#[AnAttribute]
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test attributes and doc comments are preserved.
|
||||
|
||||
/// Blah blah blah.
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
//! Doc comment
|
||||
fn test() {
|
||||
// comment
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
/// This is a long line that angers rustfmt. Rustfmt shall deal with it swiftly
|
||||
/// and justly.
|
||||
pub mod foo {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
//! This is a long line that angers rustfmt. Rustfmt shall deal with it swiftly
|
||||
//! and justly.
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Enums test
|
||||
|
||||
#[atrr]
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test expressions
|
||||
|
||||
fn foo() -> bool {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-hard_tabs: true
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Test of lots of random stuff.
|
||||
// FIXME split this into multiple, self-contained tests.
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// Struct literal expressions.
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
|
||||
// Struct literal expressions.
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
|
||||
// Struct literal expressions.
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
// rustfmt-struct_lit_style: Visual
|
||||
// rustfmt-struct_lit_multiline_style: ForceMulti
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-wrap_comments: true
|
||||
|
||||
/// A Doc comment
|
||||
#[AnAttribute]
|
||||
|
Loading…
x
Reference in New Issue
Block a user