From 1a9af9db40449abbf7614b4079352c495e1109a5 Mon Sep 17 00:00:00 2001 From: Johnothan King Date: Fri, 7 Jan 2022 07:44:05 -0800 Subject: [PATCH] Fix vi mode tab completion with spaces (#413) Attempting to complete file names in vi mode using tab completion can fail if the last character on the command line is a space. Reproducer (note that this bug doesn't occur in emacs mode): $ set -o vi $ mkdir '/tmp/foo bar' $ test -d /tmp/foo\ src/cmd/ksh93/edit/vi.c: - Don't disable tab completion or reset the tab count just because the last character on the command line is a space. This bugfix was backported from ksh93v- 2014-06-06. src/cmd/ksh93/tests/pty.sh: - Add a regression test for the tab completion bug. --- NEWS | 5 +++++ src/cmd/ksh93/edit/vi.c | 3 +-- src/cmd/ksh93/include/version.h | 2 +- src/cmd/ksh93/tests/pty.sh | 12 ++++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index b97242500..fa127e7e9 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,11 @@ For full details, see the git log at: https://github.com/ksh93/ksh Any uppercase BUG_* names are modernish shell bug IDs. +2022-01-04: + +- Fixed an issue in vi mode that caused tab completion to fail if the + last character on the command line was a space. + 2021-12-29: - Fixed numerous build errors that prevented ksh from running on Haiku OS. diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index c01e531f4..633ae2f31 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -1528,7 +1528,6 @@ static void getline(register Vi_t* vp,register int mode) if(sh_isoption(SH_VI) && mode != SEARCH && last_virt >= 0 && - (vp->ed->e_tabcount || !isblank(cur_virt)) && sh.nextprompt) { if(virtual[cur_virt]=='\\') @@ -2479,7 +2478,7 @@ addin: --cur_virt; --last_virt; vp->ocur_virt = MAXCHAR; - if(c=='=' || (modeed->e_tabcount = 0; return(APPEND); } diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index 8ad076597..f507d5dee 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -21,7 +21,7 @@ #define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */ #define SH_RELEASE_SVER "1.0.0-beta.2" /* semantic version number: https://semver.org */ -#define SH_RELEASE_DATE "2021-12-29" /* must be in this format for $((.sh.version)) */ +#define SH_RELEASE_DATE "2022-01-04" /* must be in this format for $((.sh.version)) */ #define SH_RELEASE_CPYR "(c) 2020-2021 Contributors to ksh " SH_RELEASE_FORK /* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */ diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh index a42076f9c..38bffd3ca 100755 --- a/src/cmd/ksh93/tests/pty.sh +++ b/src/cmd/ksh93/tests/pty.sh @@ -946,5 +946,17 @@ u ^OK :child-!: \r\n$ w exit ! +touch "$tmp/foo bar" +((SHOPT_VSH || SHOPT_ESH)) && tst $LINENO <