From fe393504e06e1ed58f12ce7d722d72f5cb0df394 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Wed, 13 Nov 2024 03:32:59 +0100
Subject: [PATCH] Browser: In by_1st view's prompt summaries, ellipsize prompt
 into two parts.

---
 browser.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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 = {}
-- 
2.30.2