From 3be94a7fd497f6b0b3e3e14de5a2fb14c9105e75 Mon Sep 17 00:00:00 2001 From: pghvlaans Date: Thu, 28 Jul 2022 06:33:44 +0900 Subject: [PATCH] vi mode completion: use APPEND when e_nlist is 0 (#493) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attempting to tab-complete the only member of a directory while in vi mode switches to "control" under the following conditions: 1. pwd is outside of the directory 2. No part of the basename has been typed in (e.g., starting with vim TEST/t will autocomplete to vim TEST/test, but starting with vim TEST/ will not). Also, trying to type with "input" or "replace" fails afterwards until a new line has been generated (either with ctrl + c or the j/k keys in control mode). src/cmd/ksh93/edit/vi.c: textmod(): - The strange completion behavior in vi mode for single-member directories appears to be at least partially due to completion failing to use \ or * mode from outside of pwd. Checking for e_nlist directly from vi.c — 0 unless in = mode — allows for entering the else loop at line 2575 to reach APPEND mode. Resolves: https://github.com/ksh93/ksh/issues/485 --- COPYRIGHT | 1 + NEWS | 4 ++++ src/cmd/ksh93/edit/vi.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/COPYRIGHT b/COPYRIGHT index 95b7de7db..9cc9d6264 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -25,6 +25,7 @@ ksh 93u+m general copyright notice # George Lijo # # Govind Kamat # # Harald van Dijk # +# K. Eugene Carlson # # Kurtis Rader # # Lev Kujawski # # Marc Wilson # diff --git a/NEWS b/NEWS index bbe407ffa..f5dc04796 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,10 @@ Any uppercase BUG_* names are modernish shell bug IDs. - Fixed a bug introduced on 2022-02-08 where $PPID was incorrect when a script without a #! path was executed. +- Fixed a completion bug in the vi line editor. It now correctly completes + the sole member of a directory when tab is pressed immediately after /. + Thanks to K. Eugene Carlson for the report and the fix. + 2022-07-26: - Fixed incorrect handling of initial zeros in test/[ and [[ arithmetic diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index d2335b2e9..53f74f9b2 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -2566,7 +2566,7 @@ addin: last_virt = i; ed_ringbell(); } - else if((c=='=' || (c=='\\'&&virtual[last_virt]=='/')) && !vp->repeat_set) + else if(vp->ed->e_nlist!=0 && !vp->repeat_set) { last_virt = i; vi_redraw((void*)vp);