-
-
Notifications
You must be signed in to change notification settings - Fork 574
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 a sort option popup to branch list view #2146
base: master
Are you sure you want to change the base?
Conversation
Thanks for taking a go at this! If you look at other popups like the options or search-in-log popup you will notice that the way we do these is: using the navigation cursors to pick an option instead of adding a bunch of new key bindings for each option uniquely. if you could convert this on to the same that would be awesome |
74a2c02
to
dec6128
Compare
Thank you for pointing that out. Screen.Recording.2024-03-25.at.13.26.57.mov |
d329b95
to
d30b9ac
Compare
d30b9ac
to
0c1c973
Compare
src/popups/branchlist.rs
Outdated
@@ -587,6 +706,15 @@ impl BranchListPopup { | |||
.take(height) | |||
.enumerate() | |||
{ | |||
let date_local = Local | |||
.timestamp_opt(displaybranch.top_commit_time, 0) | |||
.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to change this from an unwrap to an unwrap_or to protect from panics just incase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is this even possible to pass CI?
checkout main.rs
: #![deny(clippy::unwrap_used)]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf MappedLocalTime
: https://docs.rs/chrono/latest/chrono/offset/type.MappedLocalTime.html
lets do earliest
and then unwrap the Option with unwrap_or_else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also debating whether to store this DateTime<Local>
instead inside of BranchInfo
which should be fine as it is just
twice as big as the i64 that we we do not have to do this mess everytime the screen renders
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but at the least the unwrap needs to go
let date_text = displaybranch | ||
.top_commit_time_local | ||
.map_or("????-??-?? ".to_string(), |time| { | ||
time.date_naive().to_string() + " " | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not sure how to deal with None case.
pub top_commit_time: i64, | ||
/// | ||
pub top_commit_time_local: Option<DateTime<Local>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added top_commit_time_local
inside of BranchInfo
.
But this could be None
. I thought we should keep top_commit_time: i64
here. (top_commit_time
is used for sorting) What do you think?
// TODO: clean up | ||
#[allow(clippy::too_many_lines)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any idea to minimize this for now..
@extrawurst Sorry for the delay 🙇♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when sorting it should also keep the selection: right now it only keeps the same index selected which will mostly be a different branch when sorting changes.
the popup list entries should also not use a focused (bold) style, make it more in line with other popups (search, fuzzy find)
@extrawurst
Easier way to find new branch is required in #2129, also I think sorting is that kind of feature.
Thank you. I'll fix this. |
yes please. the use case you describe is better fixed by providing quick scroll-to-top/bottom shortcuts like we also have in the commit log list view |
148d567
to
630828e
Compare
I made an issue for this. |
This Pull Request fixes/closes #2129, #2024
It changes the following:
I followed the checklist:
make check
without errorsScreen.Recording.2024-03-22.at.19.46.23.mov