helix
helix copied to clipboard
repeat_last_motion extends selection?
If the cursor is at the beginning of a sentence that has several commas, if I do 'f,' the selection gets extended to the first comma. If I manually repeat the command, the selection now consists of the first comma up to and including the second.
But if instead of manually repeating the command, I use 'alt-.' (repeat_last_motion), the behavior is different -- the selection is extended to the second comma. I find this behavior odd because I would expect repeat_last_motion to produce the same behavior that I would get by manually repeating the last motion.
I understand that helix, while influenced by kakoune, is not a clone. But I note that kakoune does what I would expect in the situation discussed above.
I think this would be a welcome change. Currently it's hardcoded to extend: https://github.com/helix-editor/helix/blob/06d7f5d100fdcc99f4cdfda879898b2d488d8d7c/helix-term/src/commands.rs#L1263-L1265
But it could re-use that extend
parameter.
Also it might be useful as a larger refactor to have the function in Motion
take a Movement
(the enum) parameter so that you can repeat the last motion as either an extend or move based on which mode you're in.
I think this would be a welcome change. Currently it's hardcoded to extend:
https://github.com/helix-editor/helix/blob/06d7f5d100fdcc99f4cdfda879898b2d488d8d7c/helix-term/src/commands.rs#L1263-L1265
As a temporary fix, since I'm building helix from source, I changed the 4th argument of the call to find_char_impl cited above to 'false' and re-installed. repeat_last_motion now behaves as I think it should. Thanks @the-mikedavis for identifying the relevant line of code.
When I do find in normal mode, then enter select mode and then repeat_last_motion, it doesn't select text further because the closure has saved the extend=false from when the motion was executed. I find this behavior irritating. For instance, I often encounter the usecase that I want to select until a certain char, so I type f[char] but then there is a character in between those so it does not extend far enough. When I now enter select mode and repeat the motion to select until the char, it does not work because it reselects instead of extending. Do you guys not encounter this situtation? Does that not bother you?