1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

emacs: Fix digits input after completion (re: 16e4824c, e8b3274a)

Immediately after tab-completing the name of a directory, it is
not possible to type digits after the slash; ksh eats them as it
parses them as a menu selection for a nonexistent menu.

Reproducer:
$ mkdir -p emacstest/123abc
$ cd emacste[tab]123abc

Actual results:
$ cd emacstest/abc

Expected results:
$ cd emacstest/123abc

Workarounds are to press a non-numeric key followed by backspace,
or hit [tab] again to get a list of options.

Originally reported by Arnon Weinberg, 2012-12-23 07:15:19 UTC, at:
https://bugzilla.redhat.com/889745

The fix had been partially backported from ksh 93v- by AT&T
(16e4824c), which made things worse, so it was reverted (e8b3274a).
This commit backports a slightly edited version of the complete
fix. Thanks to @JohnoKing for finding the correct code. Discussion:
https://github.com/ksh93/ksh/issues/198#issuecomment-820178514

src/cmd/ksh93/edit/emacs.c: escape():
- Backport the fix for this bug that was implemented in ksh 93v-
  alpha 2013-10-10. Immediately after a slash, do not stay in "\"
  mode (file name completion) and reset the tab count.

src/cmd/ksh93/tests/pty.sh:
- Test the fix.

Resolves: https://github.com/ksh93/ksh/issues/198
This commit is contained in:
Martijn Dekker 2021-04-16 14:45:01 +01:00
parent 5fc9e64208
commit ba43436f10
4 changed files with 25 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.
2021-04-16:
- Fixed a bug in emacs mode: after using tab completion to complete the name
of a directory, it was not possible to type numbers after the slash.
2021-04-15: 2021-04-15:
- Fixed an optimization bug that caused the <>; redirection operator to fail - Fixed an optimization bug that caused the <>; redirection operator to fail

View file

@ -1008,8 +1008,14 @@ static int escape(register Emacs_t* ep,register genchar *out,int count)
case '=': /* escape = - list all matching file names */ case '=': /* escape = - list all matching file names */
ep->mark = cur; ep->mark = cur;
if(cur<1) if(cur<1)
{
beep(); beep();
else if(ed_expand(ep->ed,(char*)out,&cur,&eol,i,count) < 0) return(-1);
}
ch = i;
if(i=='\\' && out[cur-1]=='/')
i = '=';
if(ed_expand(ep->ed,(char*)out,&cur,&eol,ch,count) < 0)
{ {
if(ep->ed->e_tabcount==1) if(ep->ed->e_tabcount==1)
{ {
@ -1022,7 +1028,7 @@ static int escape(register Emacs_t* ep,register genchar *out,int count)
else if(i=='=' || (i=='\\' && out[cur-1]=='/')) else if(i=='=' || (i=='\\' && out[cur-1]=='/'))
{ {
draw(ep,REFRESH); draw(ep,REFRESH);
if(count>0) if(count>0 || i=='\\')
ep->ed->e_tabcount=0; ep->ed->e_tabcount=0;
else else
{ {

View file

@ -20,7 +20,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-alpha" /* semantic version number: https://semver.org */ #define SH_RELEASE_SVER "1.0.0-alpha" /* semantic version number: https://semver.org */
#define SH_RELEASE_DATE "2021-04-15" /* must be in this format for $((.sh.version)) */ #define SH_RELEASE_DATE "2021-04-16" /* 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

@ -786,5 +786,16 @@ r ^:test-2: echo asdf\r\n$
r ^asdf\r\n$ r ^asdf\r\n$
! !
# err_exit #
((SHOPT_ESH)) && mkdir -p emacstest/123abc && VISUAL=emacs tst $LINENO <<"!"
L autocomplete stops numeric input
# https://github.com/ksh93/ksh/issues/198
d 15
p :test-1:
w cd emacste\t123abc
r ^:test-1: cd emacstest/123abc\r\n$
!
# ====== # ======
exit $((Errors<125?Errors:125)) exit $((Errors<125?Errors:125))