1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 11:42:21 +00:00

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\ <Tab>

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.
This commit is contained in:
Johnothan King 2022-01-07 07:44:05 -08:00 committed by Martijn Dekker
parent ca5803419b
commit 1a9af9db40
4 changed files with 19 additions and 3 deletions

5
NEWS
View file

@ -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. 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: 2021-12-29:
- Fixed numerous build errors that prevented ksh from running on Haiku OS. - Fixed numerous build errors that prevented ksh from running on Haiku OS.

View file

@ -1528,7 +1528,6 @@ static void getline(register Vi_t* vp,register int mode)
if(sh_isoption(SH_VI) && if(sh_isoption(SH_VI) &&
mode != SEARCH && mode != SEARCH &&
last_virt >= 0 && last_virt >= 0 &&
(vp->ed->e_tabcount || !isblank(cur_virt)) &&
sh.nextprompt) sh.nextprompt)
{ {
if(virtual[cur_virt]=='\\') if(virtual[cur_virt]=='\\')
@ -2479,7 +2478,7 @@ addin:
--cur_virt; --cur_virt;
--last_virt; --last_virt;
vp->ocur_virt = MAXCHAR; vp->ocur_virt = MAXCHAR;
if(c=='=' || (mode<cur_virt && (virtual[cur_virt]==' ' || virtual[cur_virt]=='/'))) if(c=='=' || (mode<cur_virt && virtual[cur_virt]=='/'))
vp->ed->e_tabcount = 0; vp->ed->e_tabcount = 0;
return(APPEND); return(APPEND);
} }

View file

@ -21,7 +21,7 @@
#define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */ #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_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 #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. */ /* Scripts sometimes field-split ${.sh.version}, so don't change amount of whitespace. */

View file

@ -946,5 +946,17 @@ u ^OK :child-!: \r\n$
w exit w exit
! !
touch "$tmp/foo bar"
((SHOPT_VSH || SHOPT_ESH)) && tst $LINENO <<!
L tab completion with space in string
# https://github.com/ksh93/ksh/pull/413
d 15
p :test-1:
w echo $tmp/foo\\\\ \\t
r ^:test-1: echo $tmp/foo\\\\ bar \\r\\n$
r ^$tmp/foo bar\\r\\n$
!
# ====== # ======
exit $((Errors<125?Errors:125)) exit $((Errors<125?Errors:125))