Skip to content

Commit

Permalink
actually use TABSIZE for indents
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterNerlich committed Feb 25, 2023
1 parent ec59cc5 commit 44cef47
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pytest_icdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ def pytest_assertrepr_compare(config, op, left, right):
half_cols = COLS / 2 - MARGINS
TABSIZE = int(config.getoption("--tabsize") or 2)

pretty_left = pformat(left, indent=2, width=half_cols).splitlines()
pretty_right = pformat(right, indent=2, width=half_cols).splitlines()
pretty_left = pformat(left, indent=TABSIZE, width=half_cols).splitlines()
pretty_right = pformat(right, indent=TABSIZE, width=half_cols).splitlines()
diff_cols = COLS - MARGINS

if len(pretty_left) < 3 or len(pretty_right) < 3:
# avoid small diffs far apart by smooshing them up to the left
smallest_left = pformat(left, indent=2, width=1).splitlines()
smallest_right = pformat(right, indent=2, width=1).splitlines()
smallest_left = pformat(left, indent=TABSIZE, width=1).splitlines()
smallest_right = pformat(right, indent=TABSIZE, width=1).splitlines()
max_side = max(len(l) + 1 for l in smallest_left + smallest_right)
if (max_side * 2 + MARGINS) < COLS:
diff_cols = max_side * 2 + GUTTER
pretty_left = pformat(left, indent=2, width=max_side).splitlines()
pretty_right = pformat(right, indent=2, width=max_side).splitlines()
pretty_left = pformat(left, indent=TABSIZE, width=max_side).splitlines()
pretty_right = pformat(right, indent=TABSIZE, width=max_side).splitlines()

differ = icdiff.ConsoleDiff(
cols=diff_cols,
Expand Down

0 comments on commit 44cef47

Please sign in to comment.