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

Add undo checkpoint command #2115

Merged
merged 4 commits into from
May 2, 2022
Merged

Conversation

AntonioLucibello
Copy link
Contributor

@AntonioLucibello AntonioLucibello commented Apr 15, 2022

adds command to manually commit undo state

@AntonioLucibello AntonioLucibello restored the undo branch April 15, 2022 09:35
@AntonioLucibello AntonioLucibello changed the title added undo checkpoint command Add undo checkpoint command Apr 15, 2022
@AntonioLucibello
Copy link
Contributor Author

First time contributing to any open source project, I thought I was opening a pull request to my own fork (hence why I closed and reopened this pr in the span of 2 minutes)

@@ -319,6 +319,7 @@ impl MappableCommand {
redo, "Redo change",
earlier, "Move backward in history",
later, "Move forward in history",
add_undo_checkpoint, "Add undo checkpoint",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like commit_undo_checkpoint might read slightly better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or even commit_undo_state, but I figured calling it commit would be confusing if git integration was added in the future

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think diff and possibly blame are likely to end up in the core but any sort of git commit integration would probably live as a plugin. Since we already use "commit" when talking about history in the implementation I think commit_undo_checkpoint is reasonable

@EpocSquadron
Copy link
Contributor

This is great, welcome to the fold!

Kakoune binds this in insert mode to Ctrl-u, which I think we should do as well. Can you add it to the default keybinds?

@AntonioLucibello
Copy link
Contributor Author

AntonioLucibello commented Apr 15, 2022

Ctrl-u is already used for kill_to_line_start, should I map it to Ctrl-U? Or perhaps to Ctrl-c for "checkpoint" or "commit" (though to be fair that shortcut is very often used for copy)

@AntonioLucibello
Copy link
Contributor Author

AntonioLucibello commented Apr 15, 2022

I've added it to the keybinds as Ctrl-U in helix-term\src\keymap\default.rs, inside the let insert = keymap!({...}) block, but it doesn't seem to be working. Do I have to add it in some other place too?

edit: nevermind, it seems to be a problem with uppercase characters since Ctrl-i works fine

should I go ahead and map it to Ctrl-c?

@EpocSquadron
Copy link
Contributor

Personally I prefer maybe ctrl-s or maybe alt-u?

@AntonioLucibello
Copy link
Contributor Author

AntonioLucibello commented Apr 15, 2022

I'm in favor of Alt-u: it's similar enough to Ctrl-u and has the added advantage that Alt can be pressed easily with the left thumb while typing, unlike Ctrl which requires Extreme Left Pinky Contortion™

Considering that this command would be pressed in insert mode, I like that Alt doesn't interrupt the flow of typing the same way Ctrl does

@archseer
Copy link
Member

@pickfire opinions on this ^

I'd prefer to map the existing Ctrl-u to something else tbh and keep consistency with kakoune. Insert mode readline mappings were a mistake in my opinion, they don't fit with the helix/kakoune model.

@pickfire
Copy link
Contributor

pickfire commented Apr 21, 2022

Hmm, for my own opinion I would be prefer to keep the C-u since I use it often, kakoune keys for insert mode isn't really that good (IMHO only their normal mode keys is good, insert mode keys is bad) that I think that we need to keep consistency with kakoune for insert mode related stuff, at least vim/readline keys for insert is better I think, so both A-u and C-s is better I think, if it is me I probably would have go with A-u.

One pain point when I started using kakoune is that I always have to exit the insert mode to be able to do quick modification, especially when I typo a word wrongly and want to quickly erase it, which I missed from vim where you can just C-u and C-w to do quick edit.

@archseer
Copy link
Member

kakoune keys for insert mode isn't really that good

This is deliberate, there should be no movement in insert mode. mawww/kakoune#334 (comment)

@archseer
Copy link
Member

I'm considering removing the readline mappings but keeping the commands. That way users can re-introduce the mappings in their configs but it makes it clear that these aren't the preferred mappings.

@pickfire
Copy link
Contributor

pickfire commented Apr 21, 2022

This is deliberate, there should be no movement in insert mode. mawww/kakoune#334 (comment)

Yes, I have seen that when I started using kakoune, I still think they are useful, I had to manually specify that in kakoune and I ended up lazy to declare those (because I don't like tweaking config) so sometimes I still fallback to neovim when using kakoune because of it, I only use kakoune for multi-line edits mainly, because in insert mode, readline keys are still more powerful compared to kakoune insert mode which doesn't do anything useful.

I think these are the parts where helix can make up to the part where kakoune falls shore, one is this where it is missing useful keys in insert mode, the other one being having to hold shift when extending keys (where we use v).

But mainly I think what you said is correct, movement keys in insert mode isn't really that useful I think, like ctrl-f and ctrl-b which moves the cursor which can open up some other issues with undo or repeat, but I don't consider ctrl-u and ctrl-w movement keys given that they behave more like shortcut utilities to let you quickly delete words, if that is the case then arrow keys (do we remove the arrow keys?) and backspace are also considered movement keys, and I feel like they are in the same category, but yeah, maybe we could move the ctrl-u and ctrl-w to ctrl-backspace and alt-backspace? But I still think the vim keys seemed good.

@archseer
Copy link
Member

movement keys in insert mode isn't really that useful I think

Yeah I agree. We'll keep ctrl-u and ctrl-w for now. That means we still need to decide on a keymap for this PR then

@EpocSquadron
Copy link
Contributor

I feel like alt-u makes sense while being easy for users to adapt if we change it to ctrl-u down the road.

@pickfire
Copy link
Contributor

Like @archseer discussed on the chat

I'll probably open up a poll to see how many users use it. I also found space+w to save useful but we removed that 😛

deletion (ctrl-w, ctrl-u) are useful but I don't like the others that are only for movement. Movement should be done in normal mode

I think we probably need some sort of place to poll active users.

I also agree that those only for movements (like ctrl-f) are not useful, I don't use any of those, but IIRC on kakoune someone did ask for one of it like ctrl-e, maybe we might need it on the poll.

Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this @AntonioLucibello and aiding in the discussion of getting it alt-u while keeping the old key ctrl-u which I think is useful. \o/

Not sure if we are going to do a poll or something but I am going to let other maintainers merge this.

@pickfire
Copy link
Contributor

Hmm, while reading the tutor I wonder if ctrl-s would be a good key since it's used in normal mode. That would be it consistent with normal mode. https://github.com/helix-editor/helix/pull/2133/files#diff-0751fcdc9d0b2b023e5c02ee4941114ca1706d04e1ba73c2f4c5ba287c847074R648-R650

@pickfire pickfire mentioned this pull request Apr 24, 2022
@the-mikedavis
Copy link
Member

ctrl-s might clash with the keybinding for signature help: #1755

although ctrl-s hasn't been committed to in that PR yet

I think ctrl-s would be an especially nice binding for this though since it mirrors the key in normal mode.

@pickfire pickfire mentioned this pull request Apr 25, 2022
5 tasks
@archseer
Copy link
Member

I think ctrl-s would be an especially nice binding for this though since it mirrors the key in normal mode.

Good point. Sorry for the bike shedding, let's use ctrl-s here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants