-
-
Notifications
You must be signed in to change notification settings - Fork 592
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 cursor to TextInputComponent for better commit message support (#46) #117
Conversation
Cool @alistaircarscadden thanks for tackling this! I just had a few minor comments, would be cool if u could look into that and then it will be merged! Also please add a changelog entry |
I gave it another round of review and the biggest issue is that right now unicode is not handled and crashes |
@extrawurst Ok, fixed the behaviour when accents etc are used. The new operations walk thru the string using the &str.chars() and &str.char_indices() functions to get the next char boundary. In order to move the cursor backwards I'm walking thru the string until the previous position, which since these strings are very short takes no time at all, but if this TextInputComponent was used for some 20,000 word essay we'd want to be caching the values or something! 😀 I didn't add the changelog item because I'm currently working on a previous release. I merged the master into my branch, but can't compile anymore due to error[E0723]: heap allocations are not allowed in const fn
--> src\components\help.rs:163:19
|
163 | cmds: vec![],
| ^^^^^^
|
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) And finally, a lot of my code here makes me wish that the if and while let chains were not experimental. Some of these things could be simplified a bit. |
looks like you are not using the latest rust (1.44) then this should be fine. |
Awesome stuff man! Thanks for this ❤️ |
@alistaircarscadden I found |
Oh I actually saw that, and for some reason it didn't click. That would be super easy to use for this. I'll update my rust, thanks. |
This is one of the changes for #46 .
I've added a movable cursor to the TextInputComponent that is used to enter commit messages. This allows the user to use the arrow keys to move the cursor left and right, insert characters at the cursor. The cursor behaves naturally, moving with the text.
This change does not address the part of #46 that says characters after 50 should be red, it is very possible to make that edit to the code but will make the branching quite messy, and I will consider for a while how to best handle that logic.
This change does not address the part about multi line commit messages, and opening another editor.
I tested my changes on the commit window, I'm not sure what other functions use that TextInputComponent, and they have not been tested.