about summary refs log tree commit diff
path: root/src/comment.rs
AgeCommit message (Collapse)AuthorLines
2017-05-30Allow longer custom commenttopecongiro-48/+43
2017-05-29Use different style when rewriting comment with different openertopecongiro-27/+156
2017-05-23Format source codestopecongiro-7/+6
2017-05-18Provide `config.set().item(value)` API.Michael Killough-4/+2
This API isn't fantastic, but it's the best I can come up with without something like `concat_idents!()`. There are relatively few places where config is set, to hopefully the ugliness isn't disastrous. Change previous occurences of `config.item = value` to this new API, rather than using `config.override_value()`. Undo the changes to `override_value()`, as it's no longer important to propogate the error to the caller. Add a test for the new interface.
2017-05-16Switch to accessing config items via method.Michael Killough-8/+10
Preparation for #865, which proposes adding a flag which outputs which config options are used during formatting. This PR should not make any difference to functionality. A lot of this was search-and-replace. Some areas worthy of review/discussion: - The method for each config item returns a clone of the underlying value. We can't simply return an immutable reference, as lots of places in the code expect to be able to pass the returned value as `bool` (not `&bool). It would be nice if the `bool` items could return a copy, but the more complex types a borrowed reference... but unfortunately, I couldn't get the macro to do this. - A few places (mostly tests and `src/bin/rustfmt.rs`) were overriding config items by modifying the fields of the `Config` struct directly. They now use the existing `override_value()` method, which has been modified to return a `Result` for use by `src/bin/rustfmt.rs`. This benefits of this are that the complex `file_lines` and `write_mode` strings are now parsed in one place (`Config.override_value`) instead of multiple. The disadvantages are that it moves the compile-time checks for config names to become run-time checks.
2017-05-13Format source codeSeiichi Uchida-26/+24
2017-04-24Format source codestopecongiro-4/+1
2017-03-28fallout - source reformattingNick Cameron-4/+7
2017-03-07Formatting falloutNick Cameron-3/+7
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-02-23FalloutNick Cameron-7/+7
2017-01-31Refactor indent and width into Shape structNick Cameron-20/+20
2017-01-17Add a more lightweight method for rewriting comments when we are not normalisingNick Cameron-19/+45
Fixes #652
2016-11-21update Serde, etc.Nick Cameron-11/+7
Lots of changes to how closures work
2016-11-03Fixes a few doc typos.Fraser Hutchison-2/+2
2016-09-30Add custom comments (#1179)Florian Gilcher-0/+24
* Add custom comments This allows users to use custom comments such as ``` //@ this is a custom comment //@ with multiple lines ``` without having them destroyed by rustfmt. * Fix issues with empty lines * Check non-whitespace right after custom comments
2016-09-19Merge pull request #1161 from sinkuu/fix550Nick Cameron-4/+4
Fix #550: `if` nested in tuple is indented oddly
2016-09-17Fix #550: `if` nested in tuple is indented oddlysinkuu-4/+4
2016-09-17Improve comment rewriting with normalize_comments == falseest31-0/+10
Only change multiline comments of the form ```rust /* * Text */ ``` while not affecting comments of the form ```rust /* Text */ ``` when normalize_comments is off. In the first case, we have a known character we can align against, while we don't have one in the second case. Before, we have converted the second form into the first, but this is against the spirit of normalize_comments being turned off. Fixes #956
2016-08-29Run clippysinkuu-4/+4
2016-07-09Fix formatting empty block comments (`/**/`)sinkuu-4/+6
issue #1086
2016-06-03Fix constraints on pattern formatting of else armsMarcus Klaas-21/+23
2016-05-15change normalise spelling to American version - normalize as American ↵Srinivas Reddy Thatiparthy-1/+1
english is more common across programming community
2016-05-02Handle attributes on modules (#968)Nick Cameron-5/+5
* Handle attributes (including doc comments) on inline modules Closes #22 Closes #684 * Tweak the rules for changing indentation in comments (to do it less often).
2016-04-22Change defaults and update tests and sourceNick Cameron-19/+19
New defaults are `Tabbed` for `chain_indent` and `chain_base_indent`, and `5` for `closure_block_indent_threshold`.
2016-04-11Don't be so aggressie about line-breaking strings (#911)Nick Cameron-19/+28
We will no longer break in the middle of words, only at whitespace or punctuation. This means we sometimes over-run, but that seems better than some of the bad splits we see. Closes #369
2016-03-14Don't apply the function args heuristic to tuple lits.Nick Cameron-3/+1
Closes #450 Closes #510
2016-01-10Document comment::*CodeCharKindGaëtan Cassiers-0/+8
2016-01-10Detect when comments disappearGaëtan Cassiers-37/+225
When the reformatted code doesn't contain the same quantity of comments as the original code, use the original code instead of the reformatted code. This is done for all expressions and `let` statements. This should be used at the finest grained level possible, to avoid that a small disappearing comment prevents a big chunk of code to be reformatted. Kind of fixes (avoid disappearing comments, but prevents a good formatting is such case) #285 #225 #563 #743
2015-12-10Add normalise_comments option.Nick Cameron-10/+31
So block comments are not converted to line comments
2015-11-23Reformatting due to changesNick Cameron-2/+8
2015-11-20Blockify multiline match armsMarcus Klaas-29/+39
2015-11-10Option to disable line breaking in commentsNick Cameron-2/+3
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.
2015-10-23Remove usage of many unstable featuresAlex Crichton-1/+1
This removes usage of: * PathExt * split_last * split_last_mut * catch_panic The catch_panic one was a little tricky as the ident interner needed to be cloned across threads (a little unsafely), but it should otherwise be good to go.
2015-10-20Fix doc comment regression and add tests.Tim Kuehn-2/+9
2015-10-19Fix large block commentsMarcus Klaas-33/+86
2015-10-19Remove overflow indentationMarcus Klaas-9/+16
2015-10-19Implement CommentCodeSlicesMarcus Klaas-9/+74
2015-10-06Increase default function call width limitMarcus Klaas-2/+1
2015-09-26Changes to rustfmt sourceNick Cameron-1/+4
2015-09-26Changes to source formattingNick Cameron-3/+7
2015-09-25Make rewrite_string return `Option<String>`Marcus Klaas-50/+54
2015-09-19Add Indent::none(), remove make_indent.Pavel Sountsov-3/+2
2015-09-19Initial implementation of hard tab indentation.Pavel Sountsov-9/+22
2015-09-18Refactor test codeMarcus Klaas-4/+6
No longer use callbacks or thread::catch_panic; reduce stdout spew; guard against rustfmt breaking the column limit.
2015-09-16Format macro invocationsMarcus Klaas-0/+1
2015-09-11General cleanup after rebaseMarcus Klaas-37/+38
2015-09-11Add some tests for match blocksMarcus Klaas-15/+8
2015-09-11Add tests for chain expressionsMarcus Klaas-27/+0
2015-09-11Break chains that don't start with path expressionsMarcus Klaas-1/+0
2015-09-11Update indentation heuristics for single arg functionsMarcus Klaas-8/+8