Why was 98 chosen as the magic number? I can’t find any reference or explanation for it. Usually I see 80, 100 or 120 as the preferred line lengths in other languages.
The formatter breaks when it is possible to find a break. This is usually always possible but in many cases it cannot, such as a large double quoted string.
Another common scenario is with “do”. If all you have after the line limit is “do”, then there is no opportunity for a break before, so we effectively go line_length+2. Making it 98 means this common case fits exactly 100.
Thanks for the answer :)! There is always a space before “do” as well though - was it a conscious decision to prefer 98 over 97?
Just for a moment I thought this topic was an April’s Fool joke Being serious doen’t take the smile away. Thanks both of you
We may break in that space, or maybe we did originally. I am not a 100% sure of the current behaviour without checking.
I did a couple of manual tests earlier and found that I can create a line with a length of 101, if the formatter is set to
line_length: 98. With the setting at 97, it breaks cleanly at 100. Not that it matters much.