diff --git a/NEWS b/NEWS index b46eeb336..71067751e 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,26 @@ For full details, see the git log at: https://github.com/ksh93/ksh Any uppercase BUG_* names are modernish shell bug IDs. +2021-02-26: + +- Fixed three long-standing bugs with tab completion in the emacs editor: + + 1. The editor accepted literal tabs without escaping in certain cases, + causing buggy and inconsistent completion behaviour. Details: + https://github.com/ksh93/ksh/issues/71#issuecomment-656970959 + https://github.com/ksh93/ksh/issues/71#issuecomment-657216472 + To enter a literal tab in emacs, you need to escape it with ^V or \. + + 2. After completing a filename by choosing from a file completion menu, + the terminal cursor was placed one position too far to the right, + corrupting command line display. This happened with multiline active. + Details: https://github.com/ksh93/ksh/issues/71#issue-655093805 + + 3. A completion menu was displayed if the file name to be completed was + at the point where the rest of it started with a number, even if that + part uniquely identified it so the menu only showed one item. Details: + https://www.mail-archive.com/ast-users@lists.research.att.com/msg00436.html + 2021-02-21: - Fixed: The way that SIGWINCH was handled (i.e. the signal emitted when the diff --git a/src/cmd/ksh93/edit/completion.c b/src/cmd/ksh93/edit/completion.c index 1efc09b69..a6086f9a6 100644 --- a/src/cmd/ksh93/edit/completion.c +++ b/src/cmd/ksh93/edit/completion.c @@ -343,6 +343,8 @@ int ed_expand(Edit_t *ep, char outbuff[],int *cur,int *eol,int mode, int count) } if(mode=='\\' && out[-1]=='/' && narg>1) mode = '='; + else if(mode=='=' && narg<2) + mode = '\\'; /* no filename menu if there is only one choice */ if(mode=='=') { if (strip && !cmd_completion) diff --git a/src/cmd/ksh93/edit/emacs.c b/src/cmd/ksh93/edit/emacs.c index aa6fcd315..ef82360f5 100644 --- a/src/cmd/ksh93/edit/emacs.c +++ b/src/cmd/ksh93/edit/emacs.c @@ -371,6 +371,8 @@ int ed_emacsread(void *context, int fd,char *buff,int scend, int reedit) } ep->ed->e_tabcount = 0; } + beep(); + continue; do_default_processing: default: @@ -617,7 +619,7 @@ update: ed_crlf(ep->ed); draw(ep,REFRESH); continue; - case cntl('[') : + case ESC : vt220_save_repeat = oadjust; do_escape: adjust = escape(ep,out,oadjust); @@ -984,7 +986,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) ed_ungetchar(ep->ed,'\n'); #endif /* SHOPT_EDPREDICT */ /* file name expansion */ - case cntl('[') : /* filename completion */ + case ESC : #if SHOPT_EDPREDICT if(ep->ed->hlist) { @@ -1000,7 +1002,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count) } } #endif /* SHOPT_EDPREDICT */ - i = '\\'; + i = '\\'; /* filename completion */ case '*': /* filename expansion */ case '=': /* escape = - list all matching file names */ ep->mark = cur; @@ -1554,7 +1556,7 @@ static void draw(register Emacs_t *ep,Draw_t option) #endif /* SHOPT_MULTIBYTE */ } if(ep->ed->e_multiline && option == REFRESH) - ed_setcursor(ep->ed, ep->screen, ep->cursor-ep->screen, ep->ed->e_peol, -1); + ed_setcursor(ep->ed, ep->screen, ep->ed->e_peol, ep->ed->e_peol, -1); /****************** diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h index d848c92c8..70b696acd 100644 --- a/src/cmd/ksh93/include/version.h +++ b/src/cmd/ksh93/include/version.h @@ -20,7 +20,7 @@ #define SH_RELEASE_FORK "93u+m" /* only change if you develop a new ksh93 fork */ #define SH_RELEASE_SVER "1.0.0-alpha" /* semantic version number: https://semver.org */ -#define SH_RELEASE_DATE "2021-02-21" /* must be in this format for $((.sh.version)) */ +#define SH_RELEASE_DATE "2021-02-26" /* 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. */