-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Use builtin methods for getting selection. #1013
Conversation
Take a look at: #1026 |
Overall I think my PR #1026 is better. More importantly: it keeps backwards compatibility. Constantly changing names of exposed apis isn't good. |
In general of course, but |
@L3MON4D3 Well I think you have to export |
You'll have to expand on that, I don't see how |
Note: I'm personally depending on |
Well, mostly to allow us to do changes like this :D |
More fine-grained control over
Vague. Forcing users to use some config that is unstable across versions to config keybindings is very bad way to anything. Interference with others bindings is another concern. |
Sorry, I still don't understand how an exposed
No, the idea is to add the a function/field that exposes the rhs of the mapping to our official API (s.t. it is not unstable across versions). Users can then just call |
Sorry but I don't understand that sentence 😬 What benefit would you get from strongly depending on the fn being used in a key binding? About the part at the end about depending on the keybinding to remove the key: |
After some local testing and docs reading, I've found that using I've also found an alternative (maybe?): If we use Try it by copy/pasting |
Well, we want to do something like call lua function -> give nvim some keys to process -> call lua function (store registers -> cut -> restore registers), which can be implemented by calling the lua-functions by feeding something like
Ah, that "remove the keys" was wrong, I wanted to type "remove the text" 🤦 Sorry for the confusion. |
Ah right, because we specify a register 👍
Oh cool, yeah that looks great, I'll incorporate that 👍 |
I see one downside, using |
Phuh, yeeaaah okay, but that really does not seem like a big deal😅
Mhmm true, we could do that.. only using it in mappings is a bit weird, since we'd do pure keys -> lua-function -> pure keys, so the official mapping would still use the "leaky" rhs. |
d3d145f
to
ce3a5aa
Compare
Alright, I'd prefer to stick with only exporting the keys for now, it should work via e.g. |
Sorry @L3MON4D3 no idea how I missed this, too many noise in my notifications. You jus need to store register 9, as 1 to 8 should be now 2 to 9 so you can iterate over them and set the values back. |
Oh, no worries :)
Riiiiiiiiiiight yeah of course.. had not considered that at all xD |
9e0a57b
to
efd48fa
Compare
Easier than taking care of all the stupid edge-cases, like multibyte-combined-characters or virtualedit.
CI is lying, tests all pass :D |
Okay, there are too many edgecases for implementing this without spending wayyyy too much time on it.
This just saves all registers affected by
s
(1-9, -, unnamed, z) cuts the selected (VISUAL) text into an arbritary register (z), and then applies the code we already have to get the various variables (TM_SELECTED_TEXT, LS_SELECT_DEDENT, LS_SELECT_RAW).This is now a bit more messy (need to get all lines/positions before cutting them) so I've opted to put all of this into its own module,
util.select
.@leiserfg Could you check this over? I'm especially unsure if this will actually not change any register-state.
Once that is certain, I'll add some tests, won't go through that hassle if there's a chance we might have to scrap this :D