-
Notifications
You must be signed in to change notification settings - Fork 154
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
menu refactor #723
menu refactor #723
Conversation
the api for the menus is pretty much the same. the only breaking change is that the common builder functions (with_name, with_marker...) are now in a trait. |
Thanks @maxomatic458. We'll take a look at this soon. /cc @ysthakur I think you were thinking about going in this direction too. Your review would be helpful. |
I'll take a look too. I was actually working on that issue too, just hadn't made a PR yet, lol. I only made some helpers, though, so this PR and my branch aren't doing the same thing |
It might be good for @maxomatic458 and @ysthakur to join forces on this PR somehow because, like we said in the meeting on Wednesday, we want to avoid breaking changes as much as possible. |
i mostly got rid of code duplication by moving the builder methods in a trait (which i guess is somewhat a breaking change) |
That'd be cool. I'd made a Also, to avoid breaking changes, would it be possible to keep |
@maxomatic458 No need, you can take the stuff from my fork instead since this PR is already up |
@maxomatic458 @ysthakur once you all are in a good state with this PR I will review and test as well... |
@maxomatic458 I reviewed your code so far and it looks really good ! Great job... |
@ysthakur all great suggestions --- thanks for those and I am sure @maxomatic458 and you will get the code to a place you are both happy with... We are also not in any hurry to land this code --- its much more important that you feel comfortable with the changes you both are making --- so take as much time as you both need to figure out the best path forward... I merely did the nushell branch just so we can see so far what compiler errors are showing up on the nushell side of things. Thanks to both of you for pursuing the refactor --- its looking good so far... |
Ok, so i made a pub struct MenuSettings {
/// Menu name
name: String,
/// Menu coloring
color: MenuTextStyle,
/// Menu marker when active
marker: String,
/// Calls the completer using only the line buffer difference difference
/// after the menu was activated
only_buffer_difference: bool,
} which gets rid of all the duplicate builder functions and i made these changes here to the Menu trait pub trait Menu: Send {
/// Get MenuSettings
fn settings(&self) -> &MenuSettings;
/// Menu name
fn name(&self) -> &str {
&self.settings().name
}
/// Menu indicator
fn indicator(&self) -> &str {
&self.settings().marker
}
... to also get rid of those two functions, but this is a breaking change, because now each menu needs a implementation for settings (which could be made optional via the panic approach) and i also added all the changes from @ysthakur and for nushell, you basically just need to bring the MenuBuilder trait into scope and thats pretty much it |
@maxomatic458 @ysthakur Super fantastic job !! I got everything compiling on my nushell branch --- and ran through all of the menu types on the Nushell side of the world... https://github.com/stormasm/nushell/tree/menu_refactor_01 Everything appears to be working fine... Although it is preliminary testing, I haven't found any issues so far... The nushell side of the world could probably use a bit more testing.... Would you all mind running nushell off my branch which is up and running and working... And see if you see any oddities / weirdness on the nushell side of the world... Once you both give me the thumbs up (that you have tested my nushell branch) I will land the Reedline PR... Then we will finalize the nushell side of the world to make sure that is good... And then I will land the nushell side after that.... Again --- wow ! really cool 😄 @fdncred if you feel like doing some testing as well that would be cool... |
found an unrelated bug #727 (but thats on that also happens on the current reedline version) |
Were we able to avoid breaking changes? |
currently the only breaking changes are:
|
@maxomatic458 Everything looks good to me too! I guess we'll have to go with panicking since there's no other obvious ways to avoid a breaking change.
@fdncred The |
Breaking changes were pretty much non-existent except for some very minor issues which I already dealt with in my Nushell branch.... |
@stormasm i added a panic, so existing menu implementations (outside of nushell) will not break. |
Lets leave it in for now.... And see if anyone complains later 😄 |
@maxomatic458 @ysthakur I will test your branch more this evening and in the morning... Then I will play around with the Reedline main branch in nushell tomorrow post landing... And plan on updating Nushell with the Reedline main branch Sunday evening or Monday morning... Unless someone disagrees --- or for some reason you all don't feel its ready... This has been an incredible job ! I am impressed 😄 Thanks kindly for both of your efforts... |
I'd like to add a couple test cases for the |
You know what, never mind, it's fine if the |
we don't have to do it in this PR but it would be great to have more tests. it seems that tests are the only thing these days that guarantees other changes don't affect previous changes. i know reedline is kind of a special case since it's a line editor but we need to figure out how to do more thorough testing and have more coverage in our tests. i don't want to hold this PR up either but it would be nice to get back to tests at some point. |
@fdncred Absolutely, it just so happens that the columnar menu is already thoroughly testing |
That's good to hear. Thanks. |
Co-authored-by: Yash Thakur <[email protected]>
@maxomatic458 @ysthakur We are up and running in nushell with your newest amazing menu code !! 😄 |
remove code duplication in the menus using the
MenuCommon
struct and aMenuBuilder
trait.related #706.