Giter VIP home page Giter VIP logo

Comments (13)

merlindru avatar merlindru commented on August 17, 2024 1

Removing "selectionBehavior": "character" from dance.modes.insert fixed it! Thank you so much 😄

from dance.

71 avatar 71 commented on August 17, 2024

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.

from dance.

merlindru avatar merlindru commented on August 17, 2024

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

from dance.

71 avatar 71 commented on August 17, 2024

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".

from dance.

merlindru avatar merlindru commented on August 17, 2024

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"

image


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"

image


But if I use "selectionBehavior": "caret":

"<anchor>selectionBehavior|": "character"

image

from dance.

71 avatar 71 commented on August 17, 2024

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.

from dance.

merlindru avatar merlindru commented on August 17, 2024

@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:
image

With Dance, it lands me to the left side of the e, with the settings I posted above (block + character)

from dance.

merlindru avatar merlindru commented on August 17, 2024

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

from dance.

71 avatar 71 commented on August 17, 2024

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).

from dance.

merlindru avatar merlindru commented on August 17, 2024

That's odd. Thank you for all your help! :)

If I end up debugging it, I'll post what I've found in here

from dance.

71 avatar 71 commented on August 17, 2024

@merlindru In case you didn't see it before replying, I edited my comment with a possible solution.

from dance.

merlindru avatar merlindru commented on August 17, 2024

Thanks! Missed that. Will try

from dance.

merlindru avatar merlindru commented on August 17, 2024

Can't believe I didn't try that first. Using character selection behavior in insert mode doesn't make any sense :P

from dance.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.