-
Notifications
You must be signed in to change notification settings - Fork 720
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
w and <a-w> do not work as expected when end of selection falls on end of word. #3132
Comments
This is not wrong. If you do If you want to select a word use |
(I'm just now gave my first try to Documentation as suggested:
(It means How l works? How w works? One more thing:
Now try it out in practice:
It must be black magic because “a” is a word character that was simply skipped. I really want to know what's the explanation of this, just please don't tell it's “documented” or “it works right”. Because it doesn't... or if yes, I won't thinking anymore whether I should switch to
So you say w skips the current gray block, that's why “c” didn't become selected? Then it doesn't work well in the 100-ε percent of cases.
Between? So you say too that space is surrounded by word characters? I can also confirm from several sources that “a” is classified as a word character.
No. Sometimes people just simply need to “select the word and following whitespaces on the right of selection end” and they want to do it using w as documented. |
OK, good, I'm glad I'm not going insane, here.
Why are these:
different from this:
Please tell me you can see this glaring irregularity in how the rules are enforced. |
You're outside the document. Your problem is not that w or is not correct, but that you don't expect the way kakounes cursor works.
no selections remaining but if you have a next line:
There is an additional cursor position at the end of every line. The cursor becomes darker. If you come from vim, it is strange, but it is actually very consistent. I currently fail to find the documentation about that, maybe an longtime user can explain or point to the documentation? @Delapouite @lenormf |
You maybe misunderstood, but my issue wasn't with “no selections remaining”, but the remaining “a” before it. How the hell can it happen that I start deleting words one after another and something remains? As I noticed “w” selection always includes the character I'm standing on(*), so in this case:
“a” should be remain selected, like this:
*: That I think is against documentation if I compare the wording to “l”. |
I'm a bit wondered why this thread didn't get more (any) activity for months. I've read another inconsistency around x that skips empty lines in some circumstances... These basic things, that nobody thinks can be messed up and yet still not working after years, can took the mood of people. I'm unable to understand what are the priority tasks if not to fix these flaws as soon as possible. |
Have you considered that these things might be carefully-chosen, and not accidental? Just because you personally don't understand why a thing behaves a certain way, doesn't mean that it happened by accident. I'm not exactly sure what inconsistency around |
w is not inconsistent, it moves to the next word start, selecting from the cursor position. W does the same, with the anchor fixed. As a general rule, You can check For “x on empty lines”, it is not that it is inconsistent, but context dependent. It selects the full line, and if satisfied the next line. Contrarily to other editors, the newline character is nothing special: you can select it like any other character. It means technically, you are not on an empty line: you are on a line with the newline selected, which is the full line, so pressing x will select the next line. If you do not want that extra behavior, you have the non smart version on Alt + x. You can map it to x if you want, and experiment if you like it. As a general rule, when providing a smart or context dependent command, Kakoune provides the non smart version on Alt. It is a compromise between ease of interactivity and predictability for non interactive use, such as scripting. Kakoune normal mode is very expressive, and while trying to be orthogonal, compromises have been made for pragmatism. You can see more in the |
I found the behavior rather inconsistent. That's why I don't understand how it works.
I feel myself really-really stupid, but you say this. No?
From my previous example:
If cursor moved from the first column to the second column, why “a” is not selected if “selecting from the cursor position”?
I tried Alt+w but it behaved the same. (Maybe it's just a terminal issue though.) |
I feel like the defenders of kakoune's current behaviour aren't paying enough attention to the stated problem. Please read "Edit: a more refined test case" in the OP more carefully. |
off-topic, @zsugabubus actually, the behaviour of x is consistent. It highlights the current line, unless the current line is already highlighted, in which case it highlights the next line. When there's a one-character selection (i.e. the newline character) on an empty line, the current line is already highlighted, so it selects the next line. Personally, I find the behaviour of x jumping to the next line if the current is already highlighted totally useless, and it really should just highlight the current line, but that point's debatable. Also, |
You're right, the behavior of As I'm often myself confused about how it works, let's try to understand the code behind the Especially this condition: if (categorize<word_type>(*begin, extra_word_chars) !=
categorize<word_type>(*(begin+1), extra_word_chars))
++begin; which in my mind reads something like this: "before doing anything, let's adjust the starting point of the future selection, by observing the current character and its right neighbor. If it's not from the same family, let's move 1 char to the right first". Let's reuse the previous examples: First scenario.
Second scenario.
Third scenario.
Looks like we're onto something. So the question is: why does this strange rule exist in the first place? There's not better way to find out, that just removing it from the source code and recompiling an experimental Kakoune! I've just did it and here's what happens: if you press
So in the end the problematic is quite similar to the one expressed about the repeatability of the |
Then–the obvious question–why not But what does After all, it seems a bug to me. |
I'll try to deepen my reflection on the subject soon. Meanwhile, after a bit of research, it turns out that the question was asked a while ago: #752 but mawww explanation was pretty light. |
I didn't even realize it was inconsistent until now. I remember something similar in vim. Running commands I guess that's one of those things that I just lived with without questioning it. But I think your point is valid. |
The explanation why. (You can switch it off in nvim.)
In Vim there are inclusive and exclusive motions and motions with |
Steps
Put the following text in a buffer:
Move to the second line and do <a-h> to get your grey cursor to the beginning. If you do one <a-w>, the text "cc " at the beginning of the line will be selected. That's what is supposed to happen.
Now, try the same thing on the first line.
Outcome
The first "c" is not included in the resulting selection.
Expected
The first "c" should be in the selection.
Edit: A more refined test case:
OK, fine...
...wait, what?
OK, I declare shenanigans.
The text was updated successfully, but these errors were encountered: