Does not redraw on insert by keymap
$ ble summary
GNU bash, version 5.3.3(1)-release (x86_64-pc-linux-gnu) [NixOS 25.11 (Xantusia)]
ble.sh, version 0.4.0-devel3+1a5c451c (noarch) [git 2.39.0, GNU Make 4.3, GNU Awk 5.1.1, API: 3.1 (GNU MPFR 4.1.0-p13, GNU MP 6.2.1)]
bash-completion, version 2.16.0 (hash:480ffcc6a751e55621ec526eb5dea7a0d86d9e72, 17877 bytes) (noarch)
fzf key-bindings, (hash:50edecefb265ecdc349c0c6c39cb5d80887eff88, 5940 bytes) (noarch) (integration: on)
fzf completion, (hash:63d9d7dbd5247f1b0a39e808af8cbce41ad21715, 5497 bytes) (noarch) (integration: on)
locale: LANG=en_US.UTF-8
terminal: TERM=xterm-256color wcwidth=15.0-west/15.0-2+ri, wezterm:20220408 (1;277;0)
I have the following keymaps in .inputrc which would basically surround something with $()
blesh does not redraw when the keymap is triggered, but redraw after whatever operation that can trigger the redraw.
# .inputrc
set keymap vi-command
" z": "I$(\eA)\e"
" Z": "i$(\eA)\e"
To reproduce simply type <space>z:
https://github.com/user-attachments/assets/7f26f4a0-4c75-44cc-a990-c66d731d5f54
I confirmed the behavior.
This is not a problem with redrawing, but the last byte \e isn't actually processed and pending in the input stream until the next character appears. This is related to the ambiguity of \e: it can meanESC (or equivalently C-[) but can also be an introducer of the escape sequences that are used to represent various types of special keys such as up (\e[A), home (\e[1~), and delete (\e[3~). The problem doesn't happen with the actual user input because ble.sh uses the timing information to distinguish the two cases. In the case of string macros (set by "...": "...\e"), something related to timing detection or the distinction of the two types of \e is probably broken. I'll investigate it.
I don't know if I should open another issue but I've encountered a somehow similar problem, I want to bind double hitting Escape key to insert "sudo " at the start of the line:
function ble/widget/sudo-toggle {
if [[ "$_ble_edit_str" =~ ^sudo\ ]]
then
ble-edit/content/replace 0 5 ""
(( _ble_edit_ind -= 5 ))
(( _ble_edit_ind < 0 )) && _ble_edit_ind=0
else
ble-edit/content/replace 0 0 "sudo "
(( _ble_edit_ind += 5 ))
fi
}
ble-bind -f 'C-M-[' 'sudo-toggle'
Here I am using kinda hacky 'C-M-[' because '\e\e' does not work (the oh-my-zsh sudo plugin uses '\e\e'). And when I press Esc twice it does not redraw, until another key is pressed. If I bind it to another keyseq, like 'M-s', it won't have this problem.