The length computation of the last line in a multi-line is wrong
ZeroRin opened this issue · 1 comments
ZeroRin commented
compact-json/src/compact_json/formatter.py
Line 431 in 234356f
the current code results in a "tail" at the last line as the length of the last element is set to 0:
I think this line should be changed to
item_length + len(self.padded_comma_str)
which take into account the comma length no matter whether there will be a comma after the item. This could prevent such tail from happening when the max length is exactly 1 character less than the length of k elements with trailing comma. For example (I edited the bugged line to item_length + (len(self.padded_comma_str) if not_last_item else 0)
before running the following code):
masaccio commented
Many thanks for the patch. Latest PyPI has the change.