diff options
author | Christian Brabandt <cb@256bit.org> | 2024-05-19 09:11:09 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-05-19 09:11:09 +0200 |
commit | 0b0f7d6be08df5411718797043414a6391ebfda5 (patch) | |
tree | 7d764dda5de406a08df0e0f9e8ab3658b66b753e /src/ex_cmds.c | |
parent | 4776e64e72de2976ff90b17d236e50e2b02c5540 (diff) |
patch 9.1.0420: :browse oldfiles prompts even with single entryv9.1.0420
Problem: :browse oldfiles prompts even with single entry
Solution: Do not prompt, but edit the file directly,
also when using :filter /pat/ browse oldfiles
closes: #14794
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 2a5d842fc9..5c34e8645d 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -5622,6 +5622,9 @@ ex_oldfiles(exarg_T *eap UNUSED) listitem_T *li; int nr = 0; char_u *fname; + // for a single filtered match, remember the number + // so we can jump directly to it without prompting + int matches = -1; if (l == NULL) { @@ -5637,6 +5640,10 @@ ex_oldfiles(exarg_T *eap UNUSED) fname = tv_get_string(&li->li_tv); if (!message_filtered(fname)) { + if (matches < 0) + matches = nr; + else + matches = 0; msg_outnum((long)nr); msg_puts(": "); msg_outtrans(fname); @@ -5654,7 +5661,15 @@ ex_oldfiles(exarg_T *eap UNUSED) if (cmdmod.cmod_flags & CMOD_BROWSE) { quit_more = FALSE; - nr = prompt_for_number(FALSE); + // we only need to prompt if there is more than 1 match + if (matches > 0) + { + nr = matches; + // msg_putchar above sets needs_wait_return + need_wait_return = FALSE; + } + else + nr = prompt_for_number(FALSE); msg_starthere(); if (nr > 0) { |