Menu

#53 delete key regression

open
nobody
5
2009-07-14
2009-07-14
No

Symptom: The delete key deletes the previous character, like backspace, instead of the current character.
Appearance: This bug appeared between versions 0.9.92 and 0.9.93, by the patch at http://jline.git.sourceforge.net/git/gitweb.cgi?p=jline;a=commitdiff;h=95730df56aa31f6687d890d65a786799772ce4d1
Confusing as it is, this patch is correct; so the problem lies elsewhere.
I checked my terminal, and (out of jline) the backspace key properly emits 127, and del emits 27 91 51 126, so there's something wrong with UnixTerminal.java.
Among other things, although constant DEL_SECOND is defined, it is never used.
I'm not sure exactly what is going on with that checkBackspace method... you're setting backspaceDeleteSwitched when stty returns what it's supposed to?
Neither delete nor backspace (nor CR nor LF) really belong in keybindings.properties, since they're a basic abilities, not features. After all, the arrow keys aren't there.

Discussion

  • Hannes Wallnoefer

    I have played around a bit, and I think commit 48a2c2fd91c0c3a6f191b6010d3df2805bcdcb3a is actually to blame for this. I reversed that commit and have now both backspace and delete keys working properly on Ubuntu 9.04.

     
  • Hannes Wallnoefer

    Don't know how to attach a file here, so I'm posting the diff manually (it's trivial anyway):

    index 6f13615..8e810a8 100644
    --- a/src/main/resources/jline/keybindings.properties
    +++ b/src/main/resources/jline/keybindings.properties
    @@ -59,4 +59,4 @@

    # DELETE, CTRL-?: delete the previous character
    # 127 is the ASCII code for delete
    -127: DELETE_PREV_CHAR
    +127: DELETE_NEXT_CHAR

     
  • Charles Oliver Nutter

    I tried reverting that commit and it causes backspace to not work for me (OS X 10.6), so I think there's something else missing here.

     
  • Nonconventionally Creative

    Really, the current implementation is wrong to hard-code things, it really should query the terminfo library for the correct strings
    On linux (and Mac, from the man pages I see online), this can be done by running tput

    tput kbs #output simulates pressing backspace
    tput kdch1 #output simulates pressing 'delete next character''

     
  • Rodrigo Rosenfeld Rosas

    hns is partially right. The diff is correct but the actual commit that should be reverted is:

    95730df56aa31f6687d890d65a786799772ce4d1 - Fixed bug where the delete key deletes the next character, instead of the previous character.

    For some reason, it seems the author thinks that the correct behavior for the delete key is to delete the previous character...

     

Log in to post a comment.