Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior of extend_till_char for multiple cursors #11773

Open
TheoCorn opened this issue Sep 25, 2024 · 2 comments
Open

Unexpected behavior of extend_till_char for multiple cursors #11773

TheoCorn opened this issue Sep 25, 2024 · 2 comments
Labels
C-bug Category: This is a bug

Comments

@TheoCorn
Copy link
Contributor

Summary

Currently extend selection till (t) makes an assumption about the users intent.
Saying Hey the character you wanted to select until is right next to the cursor as you did not want to do nothing I will instead look for the character from cursor+1 which makes sense for a single cursor.

For multi cursor it is very annoying. Consider this situation:

1) something
2) another thing
     …
10) end

then setting the cursor at 1 using the commands 9Ct) one would expect to have the numbers selected in their own selections but because for numbers 1-9 ) is at cursor+1 almost all of the text is selected. Using f)vh works just fine.

This behaviour is undocumented (as far as I can tell), confusing and thus I consider it a bug. It is however very much intensional in the code.

let n = match text.get_char(pos) {
Some(next_ch) if next_ch == ch => n + 1,
_ => n,
};

Reproduction Steps

8)   commutative
9)   inversable
10) isomorphic

set cursor to 8 then 2Ct)

Helix log

No response

Platform

Linux

Terminal Emulator

Alacritty

Installation Method

source

Helix Version

helix 24.7 (b18a471)

@TheoCorn TheoCorn added the C-bug Category: This is a bug label Sep 25, 2024
@the-mikedavis
Copy link
Member

It looks like this was intentional and discussed when initially introduced: #891 (comment)

I would agree though that the command is more predicable, especially in multi-cursor scenarios, when it does nothing in the case of the search character being right next to the selection. Maybe a compromise behavior could be to check that all selections have the search character right next to the selection and only skip the character then.

About documentation though: there isn't a place currently for documenting nuances like this, that would be covered by something like #668

@TheoCorn TheoCorn changed the title Undocumented behavior of extend_till_char Unexpected behavior of extend_till_char for multiple cursors Sep 26, 2024
@TheoCorn
Copy link
Contributor Author

I think your solution is the right one.

By undocumented I meant something like #891 (comment). So I just didn't look enough.

Still, I think it could be mentioned in hx --tutor which says

helix/runtime/tutor

Lines 665 to 666 in b18a471

Type f<ch> to select up to and including (find) a character.
Type t<ch> to do the same, but not including (till) a character.

Giving a false impression. But tutor is a get started kind of thing so I get why it wasn't and maybe shouldn't be added. Something like #668 would be best.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

2 participants