From d8610a005b8ca2de8dbca1b8455573570c289b43 Mon Sep 17 00:00:00 2001 From: Rongxin Liu Date: Thu, 7 Aug 2025 21:22:14 -0400 Subject: [PATCH] increase default truncate length to improve diff visibility --- check50/_api.py | 12 +++++++++--- check50/config.py | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/check50/_api.py b/check50/_api.py index 421ef28..6ed1d4f 100644 --- a/check50/_api.py +++ b/check50/_api.py @@ -563,9 +563,15 @@ def normalize(obj): i = index break - # center around diff - start = max(i - (config.truncate_len // 2), 0) - end = min(start + config.truncate_len, len(s)) + # If the diff is within the first config.truncate_len characters, + # start from the beginning (no need for "..." at the start) + if i < config.truncate_len: + start = 0 + end = min(config.truncate_len, len(s)) + else: + # center around diff for differences further into the string + start = max(i - (config.truncate_len // 2), 0) + end = min(start + config.truncate_len, len(s)) snippet = s[start:end] diff --git a/check50/config.py b/check50/config.py index 06921a1..a7c00d1 100644 --- a/check50/config.py +++ b/check50/config.py @@ -13,7 +13,7 @@ class Config: """ def __init__(self): - self.truncate_len = 10 + self.truncate_len = 30 self.dynamic_truncate = True # Create boolean validators for your variables here (if needed):