From 378cf3f1920a62e2ed00000c66a3548baedfce5a Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Sat, 3 Jan 2026 06:09:41 -0500 Subject: show "no options" if optc=0; start at current in select_buf() --- main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index e9c3865..7b9f10c 100644 --- a/main.c +++ b/main.c @@ -1355,12 +1355,15 @@ static inline int umodi(int n, int d) { return (d + n%d) % d; } -int select_opt(Str *optv, u32 optc, Str prompt) { - if (!optc) return -1; +int select_opt_at(Str *optv, u32 optc, Str prompt, u32 opti) { + if (!optc) { + e.msg = S("no options"); + return -1; + } e.optc = optc; e.optvi = new_arr(&e.scratch, u32, optc); e.optv = optv; - e.opti = 0; + e.opti = opti; LineEditor le = line_editor(prompt, &e.scratch); int r = -1; for (;;) { @@ -1399,6 +1402,10 @@ done: return r; } +int select_opt(Str *optv, u32 optc, Str prompt) { + return select_opt_at(optv, optc, prompt, 0); +} + #include Str select_file_in(const char *path) { @@ -1467,7 +1474,7 @@ int select_buf(void) { 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: ")); + int o = select_opt_at(opt.v, opt.n, S("Buffer: "), e.bufi); if (o == -1) return -1; return o; } -- cgit v1.2.3