"Insert after" doesn't want to work
Closed this issue · 13 comments
I'm not sure if I misunderstood anything about how Kakoune works (I've only ever used Dance), but pressing a
should put me into insert mode after the selection, right?
On my end, a
and i
do the same thing. This happens both with and without "selectionBehavior": "character"
.
Any idea about what could be going on?
Thanks for building this amazing extension!
Hi, and thanks for the report! Even when you have long selections a
goes to the beginning? Are you sure that you didn't override was a
does in VS Code keybindings? I don't really know where the error can come from, I think your best shot is to clone the Dance repo, open it in VS Code, and run the extension. This will allow you to debug it (with breakpoints) and see what happens when you press a
.
Thanks for the quick reply! When I have a long beginning, a does go to the end of that selection, but inserts the character before the last char of the selection. Maybe this is intended?
<anchor>asdfasdfasdf<cursor>
If this ^ is my selection and I press a
, this happens:
asdfasdfasd<cursor>f
but I expected this:
asdfasdfasdf<cursor>
Which made me think a
and i
did the same thing. They don't! But it still seems unusual
And this also happens with "selectionBehavior": "caret"
? My guess is that you either have "selectionBehavior": "caret"
with "cursorStyle": "block"
, or "selectionBehavior": "character"
with "cursorStyle": "line"
.
Oh! That clears it up!
This was my config:
"dance.modes": {
"input": {},
"insert": {
"selectionBehavior": "character"
},
"normal": {
"cursorStyle": "block",
"selectionBehavior": "character"
}
},
When using "selectionBehavior": "caret"
it works as expected!
Is this me misunderstanding how it's supposed to work/how kak works, or is this a bug with "selectionBehavior": "character"
?
For example:
"|selectionBehavior": "caret"
Pressing w
does this (I don't think saying it has two anchors is technically correct, but the whole word is definitely selected)
"<anchor>selectionBehavio|r<anchor>": "character"
But if I use "selectionBehavior": "caret"
:
"<anchor>selectionBehavior|": "character"
Dance "character"
selection behavior is meant to work with "block"
cursor style because it internally converts a selection like selectionBehavio|r
(as seen by VS Code) into selectionBehavior|
(as seen by Dance) because with a block cursor, it looks like selectionBehavio[r]
is selected even though VS Code considers that the selection ends before r
. Perhaps a warning should be emitted that "cursorStyle": "line"
(the default) doesn't work well with "selectionBehavior": "character"
.
Note that Kakoune doesn't have that concept; "caret"
selection behavior is simply the native VS Code selection behavior, and "character"
selection behavior is an emulation of how Kakoune works for Dance commands (because in VS Code fo[o]
(with the block on the last o
) only considers fo
in the selection, whereas in Kakoune it considers foo
). Dance used to work differently (by modifying the style of the collection instead of using a "block"
character style, avoiding having to translate selections in some cases), but this led to even more issues.
@71 I disabled "cursorStyle": "block"
just for the sake of the example -- I've posted the settings I'm usually using above :P
Again, I'm not sure how it's in Kak, but with Helix, pressing a
lands my cursor to the right side of the block. Something like this:
With Dance, it lands me to the left side of the e, with the settings I posted above (block + character)
That's why I filed this issue in the first place, it looks just like it does with e.g. Helix (my block cursor is over the character) but when I press a
, Dance acts as if it's not
I tried it on my end and pressing a
in your example on Dance (block + character) goes to the right side of e
as expected. I'm not sure what's going wrong on your end, so I'd suggest debugging Dance when you press a
. You can put a breakpoint here and look at various locals to see what command is being executed; in theory, its name should be dance.modes.insert.after
.
Edit: are you still using "selectionBehavior": "character"
in "insert"
mode? That might be the issue, as it should always be set to "caret"
(again, I should probably add a warning here, but Dance is designed to be easily extensible so it sounds a bit weird to me).
That's odd. Thank you for all your help! :)
If I end up debugging it, I'll post what I've found in here
@merlindru In case you didn't see it before replying, I edited my comment with a possible solution.
Thanks! Missed that. Will try
Removing "selectionBehavior": "character"
from dance.modes.insert
fixed it! Thank you so much 😄
Can't believe I didn't try that first. Using character selection behavior in insert mode doesn't make any sense :P