ksh: Tab completion menu causes inconsistent editor state in emacs
Line editing is set thus:
[44] mbp13 $ set -o
emacs on
vi off
viraw on
Start typing, get to bin/p, hit TAB. Nothing happens. Hit TAB again. (why do I have to hit TAB twice?) Get:
[04:59 PM][ttys001][~]
[45] mbp13 $ bin/p
1) pkg-config
2) pscal
3) pscal.saf
[45] mbp13 $ bin/pscal
Hit ‘2’, hit TAB again, shell fills out bin/pscal.
[45] mbp13 $ bin/pscal
Now, backspace over the command line…
[04:59 PM][ttys001][~]
[45] mbp13 $ bin/p
1) pkg-config
2) pscal
3) pscal.saf
[45] mbp13 $ b
I’m left with the ‘b’, which isn’t actually there, I can hit ENTER and not get an error message, and it’s not stored in history.
10.15.5, ksh93u+m, ksh93u+ does it too.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 37
Commits related to this issue
- editors: fix broken SIGWINCH handling In the emacs editor: 1. press ESC 2. change the size of your terminal window and your screen is mysteriously cleared. (Until recent fixes, the shell probably... — committed to ksh93/ksh by McDutchie 3 years ago
- Turn multiline back on now that https://github.com/ksh93/ksh/issues/71 is fixed — committed to posguy99/dotfiles by posguy99 3 years ago
@McDutchie: Just hang in there. I, for one, know that you are doing a good job with this new ksh93 endeavor. Please take a break and get some rest. Perhaps take a day off and relax. Because, there is other fruit to pick from the issues tree.
I did a bit of research on this, and I think the fix to have the Emacs editing mode do the same as Vi is correct.
From RELEASE: 08-05-01 In multiline edit mode, the refresh operation will now clear the remaining portion of the last line.
Here’s a fragment from the completion.c of the venerable but dated CDE DtKsh:
Noticeably missing is the code to add a space after file name completions. So, it seems plausible that if multiline editing mode was added beforehand,the ep->ed->p_eol != ep->cursor-ep->screen case might never have occurred during testing.
Setting the ‘first’ parameter to -1 seems to be a pretty explicit indicator that the author(s) intended the line clearing code to run, hence the entry in RELASE.
The real issue is that if we update the cursor by calling ed_setcursor on line 1554 with old != new, the later call to setcursor on line 1583, here:
will use outdated screen information to call setcursor, which, coincidentally, calls ed_setcursor.
Well, that was quite the adventure… Could we add issue IDs/bug numbers to the regression tests, perhaps? It seems like useful information to catalog the defect delta from the last AST release, considering the effort going into this project.
Sorry, but… this is with patches 2&3 and the latest patch 1…
What little I can quickly find without trying to understand the code: with the following debug patch:
After the Enter after tab completion, the
S_EOF
case is hit again, and the call tolexfill(lp)
is what causes the prompt for more input (I think).After the Enter without tab compltion, the
S_EOF
case is not hit again.Hopefully this will speed up a deeper investigation by someone who actually understands the code.
Oh, man, number 3 is so cool, it’s like a pain you don’t know how to get rid of until it’s suddenly just… gone. What crazy person EVER thought the original behavior was a correct one?
Ahem.
Ok, number 1… yup, fixes it. behavior is correct now with multiline on or off… no extra space and no hanging characters.
For number 2, also fixes it, just get a terminal beep now with a TAB rather than a jump to the next tabstop and then a menu full of everything.
Is this one part of the same issue or is it a new issue? Found this on the old ast-users ML, apparently the user complaining about his issue got told it was normal behavior, but in testing that, I found this:
hit TAB
Four spaces get inserted. Why? Hit TAB again
Huh? This time it did the filename completion. Hit TAB again
And now it displays the completion list menu?
There’s some confusion going on here between what KSH does if it’s trying to complete a command (the first token on the line) and trying to complete a filename (everything else).
The original thread: https://www.mail-archive.com/ast-users@lists.research.att.com/msg00419.html The simpler testcase: https://www.mail-archive.com/ast-users@lists.research.att.com/msg00436.html