summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWormHeamer2026-01-02 21:59:56 -0500
committerWormHeamer2026-01-02 21:59:56 -0500
commitb500b367f022853043801264140f91d6ac5b5640 (patch)
treef0379c3520ce2e6897b844bd9d4646a58ce3c485
parent224d2deb2711682fcce843ab4a46b310108db5fb (diff)
don't strip shared prefix from buffer paths anymore
shorten_path() has rendered this obsolete
-rw-r--r--main.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/main.c b/main.c
index 7942692..17d899c 100644
--- a/main.c
+++ b/main.c
@@ -1382,30 +1382,12 @@ Str select_file(void) {
return s;
}
-Str minimum_prefix(Str *s, u32 n) {
- if (!n) return (Str) { 0, 0 };
- Str p = s[0];
- for (u32 i = 1; i < n; i++) {
- u32 pn = 0;
- while (pn < s[i].n && p.s[pn] == s[i].s[pn]) pn++;
- if (pn < p.n) p.n = pn;
- }
- return p;
-}
-
int select_buf(void) {
DYNARR(Str) opt = { 0 };
DA_AFIT(&opt, &e.scratch, e.bufn);
- for (u32 i = 0; i < e.bufn; i++) {
- DA_APUSH(&opt, &e.scratch, shorten_path(e.buf[i].path, &e.scratch));
- }
- ASSERT(opt.n == e.bufn);
- Str prefix = minimum_prefix(opt.v, opt.n);
- while (prefix.n > 0 && prefix.s[prefix.n-1] != '/') prefix.n--;
- for (u32 i = 0; i < opt.n; i++) {
- ASSERT(opt.v[i].n > prefix.n);
- opt.v[i] = str_skip(opt.v[i], prefix.n);
- }
+ opt.n = e.bufn;
+ for (u32 i = 0; i < e.bufn; i++)
+ opt.v[i] = shorten_path(e.buf[i].path, &e.scratch);
int o = select_opt(opt.v, opt.n, S("Buffer: "));
if (o == -1) return -1;
return o;