topecongiro
d3d31a9f75
Allow overflowing the last item of chain only if it is multi-lined
...
By multi-lined we mean if it has more than 3 lines.
2017-06-16 08:47:33 +09:00
Nick Cameron
18ccd0190e
Rebasing
2017-06-13 14:49:47 +12:00
Nick Cameron
1f512948a0
Reformat source code using new defaults
2017-06-13 14:41:49 +12:00
est31
727963afe4
Update syntex_syntax
...
Bases on commit to switch to libsyntax by @nrc
2017-06-06 07:31:47 +02:00
topecongiro
7250a468f9
Format source codes
2017-06-05 15:32:21 +09:00
topecongiro
0292640e14
Allow chain item to extend if the parent ends with closing parens and alike
2017-06-05 15:31:05 +09:00
topecongiro
b49269ad39
Forbid method chain to get combined if it uses multi line.
...
If the method chain goes multi line before the last element, disallow combining
the method chain.
2017-06-04 19:37:24 +09:00
topecongiro
fabbef2c3e
Add macro to block expr
2017-06-04 19:35:29 +09:00
topecongiro
fef347cb9e
Add use_block_indent
method to RewriteContext
2017-06-04 19:35:29 +09:00
topecongiro
b63e3aaa83
Put a space between nested tuple field
2017-05-30 20:40:05 +09:00
topecongiro
554605d47c
Format source codes and add tests
2017-05-26 16:40:19 +09:00
topecongiro
2580d7a310
Add chain_split_single_child option
2017-05-25 16:07:56 +09:00
topecongiro
c69608a7e0
Allow the last elem in chain to overflow
2017-05-25 15:50:46 +09:00
topecongiro
635fdc662a
Format source codes
2017-05-25 15:50:46 +09:00
topecongiro
6aed417738
Disallow single line chain when the line exceeds the given budget
2017-05-25 15:50:46 +09:00
topecongiro
857747c9ca
Consider trailing try operations when counting almost_total
2017-05-25 15:50:46 +09:00
Nick Cameron
393ba27311
Remove dependency on Itertools
2017-05-25 16:23:07 +12:00
topecongiro
92b54d6490
Add heuristic when rewriting chain with a single child
...
rustfmt splits chain into multiline when the length of chain exceeds
`chain_one_line_max`. However, currenly this rule only applies when the chain
has more than one child. This can lead to unexpected long chain if the parent
is long. This commit adds heuristic that if the length of parent is longer
than the half of `chain_one_line_max` we use multiline even if there is
only a single child.
2017-05-24 00:06:23 +09:00
topecongiro
cb4a6a2419
Use correct width when rewriting chain
2017-05-23 22:12:52 +09:00
topecongiro
a83d4876e7
Allow first child to stay on the same line with block parent
2017-05-23 22:12:37 +09:00
topecongiro
f2ec5a7bac
Refactor source codes
2017-05-23 11:37:12 +09:00
topecongiro
13af774e55
Fix weird indentaion in chain
2017-05-23 11:37:12 +09:00
Michael Killough
c3c2e823cb
Merge branch 'master' of https://github.com/rust-lang-nursery/rustfmt into config
2017-05-18 13:05:19 +07:00
topecongiro
d7b6f1199f
Format source codes
2017-05-16 23:24:38 +09:00
topecongiro
feff6248c4
Allow last child in chain to go multiline
2017-05-16 23:24:00 +09:00
Michael Killough
c0bdbfa531
Switch to accessing config items via method.
...
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-16 15:47:09 +07:00
Seiichi Uchida
7ec78711f2
Prevent rewriting closure block to expr inside macro
2017-05-13 18:32:25 +09:00
topecongiro
e91d498b8f
Keep a chain with length chain_one_line_max in a single line
2017-05-03 11:24:08 +09:00
topecongiro
2c1d896f60
Split a long chain with a single child
2017-05-03 11:22:36 +09:00
Nick Cameron
c546f1b396
Merge pull request #1454 from topecongiro/match
...
Format nested mathces properly.
2017-05-02 10:40:31 +12:00
topecongiro
af3f4c7f29
Remove duplicates
2017-05-01 15:57:02 +09:00
topecongiro
3d2cd681ae
Use 'first_line_width'
2017-05-01 15:36:40 +09:00
topecongiro
02cf515be6
Format source codes
2017-04-24 16:50:11 +09:00
topecongiro
cbd33e1983
Remove '+ 1' when counting the length of chains
2017-04-24 16:48:05 +09:00
topecongiro
8dc53d3750
Check the length of the first line of the last method in the chain
2017-04-15 16:23:38 +09:00
Nick Cameron
bdcb8d663e
Merge pull request #1438 from topecongiro/poor-formatting/method-chains
...
Lookup the last element of 'subexpr_list' instead of the first one
2017-04-06 21:26:13 +12:00
topecongiro
8d22e85e48
Lookup the last element of 'subexpr_list' instead of the first one
...
Closes #1217 , #1236 , #1389 and #1434 .
2017-04-06 09:26:25 +09:00
Ryan1729
4c4f70957b
fix bug by adding boolean argument
...
Signed-off-by: Ryan1729 <Ryan1729@gmail.com>
2017-04-03 17:39:14 -06:00
Nick Cameron
5305bc8436
test fallout
2017-03-28 11:25:59 +13:00
Nick Cameron
5fb1140688
fallout - source reformatting
2017-03-28 11:14:47 +13:00
Nick Cameron
a079b87e7c
Use a char len heuristic rather than item count for chain_one_line_max
2017-03-28 11:12:15 +13:00
Nick Cameron
e4efa22983
Source formatting fallout
2017-03-28 10:58:41 +13:00
Nick Cameron
038436919d
Put the second element of a chain on its own line when block formatting.
2017-03-28 10:56:46 +13:00
Nick Cameron
488c0b9546
Test and source fallout
2017-03-22 09:25:26 +13:00
Nick Cameron
21ff1d43ba
Unify a bunch of option types into IndentStyle
2017-03-20 11:46:39 +13:00
Nick Cameron
ce7b0aacd0
Remove BlockIndentStyle::Inherit
2017-03-20 11:23:44 +13:00
Nick Cameron
33b83ae7df
Formatting fallout
...
Also fixes a minor bug when we break a line after `if` and used to leave a trailing space
2017-03-07 09:50:41 +13:00
Nick Cameron
c7a33062e2
Add a heuristic for maximum number of elements in a single-line chain
...
And turn the source hints option to false by default. This should make formatting more deterministic.
2017-03-07 09:34:28 +13:00
Nick Cameron
a7612cc773
more fallout
2017-02-23 13:15:48 +13:00
Nick Cameron
d9d2423764
Tweak chain rules
2017-02-23 13:15:48 +13:00