From: Christian Heller Date: Wed, 13 Nov 2024 02:32:59 +0000 (+0100) Subject: Browser: In by_1st view's prompt summaries, ellipsize prompt into two parts. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/reset_cookie?a=commitdiff_plain;h=fe393504e06e1ed58f12ce7d722d72f5cb0df394;p=stable_plom Browser: In by_1st view's prompt summaries, ellipsize prompt into two parts. --- diff --git a/browser.py b/browser.py index 81ec887..89eabad 100755 --- a/browser.py +++ b/browser.py @@ -854,10 +854,21 @@ class Gallery: if suffix: for i, p in enumerate(cores): cores[i] = p[:-len(suffix)] + longest_total = '' + for i in range(len(cores[0])): + temp_longest = find_longest_equal(cores, j=i, matcher='in') + if len(temp_longest) > len(longest_total): + longest_total = temp_longest + middle = longest_total for i, p in enumerate(prompts): + remains = p[len(prefix):] + idx_middle = remains.index(middle) + second = remains[:idx_middle] + remains = remains[idx_middle + len(middle):] + first = remains[:-len(suffix)] if suffix else remains pre_ell = '…' if prefix else '' post_ell = '…' if suffix else '' - prompts_diff[p] = f'{pre_ell}{cores[i]}{post_ell}' + prompts_diff[p] = f'{pre_ell}{first}…{second}{post_ell}' return prompts_diff basic_items_attrs = {}