helix
helix copied to clipboard
Allow chaining `find_next_char`, `select_textobject_around`, etc. together with other commands in keymaps
There are quite a few commands that expect an argument in the form of a single character:
find_till_charfind_next_chartill_prev_charfind_prev_charsurround_addsurround_replace(this one even expects two arguments)surround_deleteselect_textobject_aroundselect_textobject_inner
However, it doesn't seem possible to chain these together with other commands in keymaps.
For example:
[keys.normal]
f = ["find_next_char", "collapse_selection"]
does not work as expected. The collapse_selection command seems to be completely ignored.
Similarly, this
[keys.normal]
C = ["select_textobject_inner", "change_selection"]
seems to execute the change_selection command immediately, before select_textobject_inner has finished.
My enhancement request is that if these commands with arguments appear in a keymap, they should first finish completely and then the next command in the list should be called.
I'm taking a stab at fixing this. I got a fix that works but needs a bit more work before I open a pull request.
The ones related to select_textobject_inner are basically sub menus but the commands behind the items in the popup do not have command names themselves. For instance there really should be IMO a select_textobject_inner_word to do miw. I wonder if it would be a good idea to just name those commands and expose them for custom mappings.
Although w, e and b, are great for selecting words automatically, I think f should change the default behavior like the key map below. In my case, It's more common for using without selecting. Is there any common case of using f with selection?
[keys.normal]
f = ["find_next_char", "collapse_selection"]
Not sure why, but to chain some commands, sometimes they requires a :, and sometimes not:
The following works fine for me. (Typing AltGr + d output ð on my French keyboard)
Notice the erratic usage of :.
It is a confusing behavior.
# Works fine: Duplicate line with AltGr + d
"ð" = ["extend_line_below", ":clipboard-yank", "open_below", ":clipboard-paste-before"]
# Doesn't work: Fail to load config (due to : on open_below)
"ð" = ["extend_line_below", ":clipboard-yank", ":open_below", ":clipboard-paste-before"]