a_tty__bind_tree_add_wc(): FIX: shadow bindings (Koichi Murase)..
commit3c52d1697aa5365f4edb6febf90222fef97be839
authorSteffen Nurpmeso <steffen@sdaoden.eu>
Sun, 19 Jan 2020 02:09:40 +0000 (19 03:09 +0100)
committerSteffen Nurpmeso <steffen@sdaoden.eu>
Sun, 19 Jan 2020 02:25:09 +0000 (19 03:25 +0100)
tree83260c33e4f78cfb8a49a1e58a78dbf0cbcce8df
parent350e4be5b9fa4b4a0c100c10eb2e11166082ae13
a_tty__bind_tree_add_wc(): FIX: shadow bindings (Koichi Murase)..

I saw on bug-bash@ a report from Koichi Murase

  >>    $ LANG=C bash --norc
  >>    $ bind -x '"\C-t\C-t":echo hello'
  >>    $ bind -x '"\C-t":echo world'
  >>    $ <-- <C-t><wait 500ms>
  >>    hello     #<-- expected result is "world"

and testing around a bit revealed quite a lot of problems with our
key-binding code.  For which i have never found any time for just
a single real, deep review in all that time.  Sigh.  What a mess.
So in a $MAILRC

   set line-editor-no-defaults
   bind base $'\n' mle-commit
   bind base $'\c?' mle-del-bwd
   bind base $'\cE' mle-go-end
   bind base $'\c[' mle-cancel
   bind base $'\cT' echo one
   bind base $'\cT',$'\cT' echo two
   bind base abc echo 0
   bind base ab,c echo 1
-is in, but never found (finds abc/0)
-with THIS commit it finds a,b,c instead
   bind base abc,d echo 2
   bind base ac,d echo 3
   bind base a,b,c echo 4
-not in (never found)
+ok with this commit
   bind base a,b,c,d echo 5
-not in (never found)
+ok with this commit
   bind base a,b,cc,d echo 6
=if this is placed before "a,b,c" then 4 and 5 are in and (also) found!
   bind base d,e,f echo made me chef
   bind base ü,ä echo au
   set quiet noheader
   set bind-inter-key-timeout=3000
   set bind-inter-byte-timeout=250

(This already uses new diverse bind timeouts that will be in
v14.9.10.)  The test also revealed that we placed all CANCEL
etc. shortcuts in the base context, what became
[350e4be5b9fa4b4a0c100c10eb2e11166082ae13].
The ab,c issue is still not solved, but the shadow issue, which
looked like (using the v14.9.10 commit (`bind': with -vvv or -d,
dump the built lookup tree)):

  s-nail:   - default:
  s-nail:     . 0x0064/d
  s-nail:       . 0x0065/e
  s-nail:         . 0x0066/f (echo made me chef)
  s-nail:     . 0x0005/? (mle-go-end)
  s-nail:     . 0x001B/? (mle-cancel)
  s-nail:     . 0x007F/? (mle-del-bwd)
  s-nail:     . 0x0014/? (echo one)
  s-nail:       . 0x0014/? (echo two)
  s-nail:     : 0x0061/a
  s-nail:       : 0x0062/b
  s-nail:         : 0x0063/c (echo 0)
  s-nail:           . 0x0064/d (echo 2)
  s-nail:         . 0x0063/c (echo 1)
  s-nail:       : 0x0063/c
  s-nail:         . 0x0064/d (echo 3)
  s-nail:     . 0x0061/a
  s-nail:       . 0x0062/b
  s-nail:         : 0x0063/c
  s-nail:           : 0x0063/c
  s-nail:             . 0x0064/d (echo 6)
  s-nail:     . 0x000A/? (mle-commit)
  s-nail:     . 0x00FC/?
  s-nail:       . 0x00E4/? (echo au)

is solved with this commit, it now looks

  s-nail:   - default:
  s-nail:     . 0x0064/d
  s-nail:       . 0x0065/e
  s-nail:         . 0x0066/f (echo made me chef)
  s-nail:     . 0x0005/? (mle-go-end)
  s-nail:     . 0x001B/? (mle-cancel)
  s-nail:     . 0x007F/? (mle-del-bwd)
  s-nail:     . 0x0014/? (echo one)
  s-nail:       . 0x0014/? (echo two)
  s-nail:     : 0x0061/a
  s-nail:       : 0x0062/b
  s-nail:         : 0x0063/c (echo 0)
  s-nail:           . 0x0064/d (echo 2)
  s-nail:         . 0x0063/c (echo 1)
  s-nail:       : 0x0063/c
  s-nail:         . 0x0064/d (echo 3)
  s-nail:     . 0x0061/a
  s-nail:       . 0x0062/b
  s-nail:         : 0x0063/c
  s-nail:           : 0x0063/c
  s-nail:             . 0x0064/d (echo 6)
  s-nail:         . 0x0063/c (echo 4)
  s-nail:           . 0x0064/d (echo 5)
  s-nail:     . 0x000A/? (mle-commit)
  s-nail:     . 0x00FC/?
  s-nail:       . 0x00E4/? (echo au)

So this was a simple linking issue.  The new code is also smaller.
src/mx/tty.c