From: Ɓukasz Langa Date: Mon, 24 Aug 2020 16:29:59 +0000 (+0200) Subject: Address pre-existing trailing commas when not in the rightmost bracket pair X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/586d24236e6b57bc3b5da85fdbe2563835021076?hp=586d24236e6b57bc3b5da85fdbe2563835021076 Address pre-existing trailing commas when not in the rightmost bracket pair This required some hackery. Long story short, we need to reuse the ability to omit rightmost bracket pairs (which glues them together and splits on something else instead), for use with pre-existing trailing commas. This form of user-controlled formatting is brittle so we have to be careful not to cause a scenario where Black first formats code without trailing commas in one way, and then looks at the same file with pre-existing trailing commas (that it itself put on the previous run) and decides to format the code again. One particular ugly edge case here is handling of optional parentheses. In particular, the long-standing `line_length=1` hack got in the way of pre-existing trailing commas and had to be removed. Instead, a more intelligent but costly solution was put in place: a "second opinion" if the formatting that omits optional parentheses ended up causing lines to be too long. Again, for efficiency purposes, Black reuses Leaf objects from blib2to3 and modifies them in place, which was invalid for having two separate formattings. Line cloning was used to mitigate this. Fixes #1619 ---