diff --git a/NEWS b/NEWS index 2d2e5fddd..ee018af28 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. +2020-06-24: + +- Fixed buggy tab completion of tilde-expanded paths such as + ~/some in 'vi' mode. + 2020-06-23: - Fixed a bug that caused combining process substitution with redirection diff --git a/src/cmd/ksh93/edit/vi.c b/src/cmd/ksh93/edit/vi.c index 5eeaa3078..41fa1cbdc 100644 --- a/src/cmd/ksh93/edit/vi.c +++ b/src/cmd/ksh93/edit/vi.c @@ -2391,6 +2391,7 @@ static int textmod(register Vi_t *vp,register int c, int mode) register genchar *p = vp->lastline; register int trepeat = vp->repeat; genchar *savep; + int ch; if(mode && (fold(vp->lastmotion)=='F' || fold(vp->lastmotion)=='T')) vp->lastmotion = ';'; @@ -2421,7 +2422,10 @@ addin: ++last_virt; mode = cur_virt-1; virtual[last_virt] = 0; - if(ed_expand(vp->ed,(char*)virtual, &cur_virt, &last_virt, c, vp->repeat_set?vp->repeat:-1)<0) + ch = c; + if(mode>=0 && c=='\\' && virtual[mode+1]=='/') + c = '='; + if(ed_expand(vp->ed,(char*)virtual, &cur_virt, &last_virt, ch, vp->repeat_set?vp->repeat:-1)<0) { if(vp->ed->e_tabcount) { @@ -2433,9 +2437,8 @@ addin: last_virt = i; ed_ringbell(); } - else if((c=='=' || (c=='\\'&&virtual[i]=='/')) && !vp->repeat_set) + else if((c=='=' || (c=='\\'&&virtual[last_virt]=='/')) && !vp->repeat_set) { - last_virt = i; vp->nonewline++; ed_ungetchar(vp->ed,cntl('L')); return(GOOD); diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index 68de657f0..041e40b3b 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -17,4 +17,4 @@ * David Korn * * * ***********************************************************************/ -#define SH_RELEASE "93u+m 2020-06-23" +#define SH_RELEASE "93u+m 2020-06-24" diff --git a/src/cmd/ksh93/tests/pty.sh b/src/cmd/ksh93/tests/pty.sh index 9a8a9b7d3..d4c445eb1 100755 --- a/src/cmd/ksh93/tests/pty.sh +++ b/src/cmd/ksh93/tests/pty.sh @@ -453,4 +453,22 @@ w fg u yes-yes ! +# ====== +# err_exit # +# Test file name completion in vi mode +mkdir /tmp/fakehome +tst $LINENO <<"!" +L vi mode file name completion + +# Completing a file name in vi mode that contains '~' and has a +# base name the same length as the home directory's parent directory +# shouldn't fail. + +w set -o vi; HOME=/tmp/fakehome; touch ~/testfile +w echo ~/tes\t +u ^/tmp/fakehome/testfile\r?\n$ +! +rm -r /tmp/fakehome + +# ====== exit $((Errors<125?Errors:125))