-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Enable PgUp/PgDown and Home/End in the command palette #7835
Conversation
Hey there! You can keep updating the same pull request, you don’t have to make a new one every time! 😄 it might be a little easier for you to manage that way! |
My only real qualm with this PR is hardcoding the height to 42. I'd really rather not do that, and use the |
Yes I don't like it is being hardcoded either. I will try a little bit more. |
const auto selected = _filteredActionsView().SelectedIndex(); | ||
const int numItems = ::base::saturated_cast<int>(_filteredActionsView().Items().Size()); | ||
// Wraparound math. By adding numItems and then calculating modulo numItems, | ||
// we clamp the values to the range [0, numItems) while still supporting moving | ||
// upward from 0 to numItems - 1. | ||
const auto newIndex = ((numItems + selected + (moveDown ? 1 : -1)) % numItems); | ||
const auto newIndex = ((numItems + selected + (moveDown ? (pageButtonPressed ? numVisibleItems : 1) : (pageButtonPressed ? -numVisibleItems : -1))) % numItems); |
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.
The logic duplication can be avoided by extracting a "delta" variable: moveDown? delta : -delta
{ | ||
const auto listHeight = ::base::saturated_cast<int>(_filteredActionsView().ActualHeight()); | ||
const int numVisibleItems = listHeight / 42; |
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.
If 42 cannot be computed, consider extracting it to a const and documenting why this value was chosen
// - moveDown: if true, we're attempting to move to the next item in the | ||
// list. Otherwise, we're attempting to move to the previous. | ||
// - moveDown: if true, we're attempting to move to the next or a few next item in the | ||
// list. Otherwise, we're attempting to move to the previous or not very many previous. |
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.
Document the new parameter
I've been trying to generate |
I wonder if we can get rid of the 42 by using... |
I have no idea how to measure the object that I got from |
Is this commit better than before? At least hardcoded |
previous commit was draft
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.
What happened to trying ContainerFromIndex
? Does the following work to get the item's height?
auto f = _filteredActionsView().ContainerFromIndex(0);
auto g = f.try_as<winrt::Windows::UI::Xaml::Controls::ListViewItem>();
auto h = g.ActualHeight();
I think that should work, but g
might end up being null. If it is, I'd maybe try casting it to a FrameworkElement
instead
{ | ||
const auto itemHeight = ::base::saturated_cast<int>(_parentCommandText().Height()); |
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 wouldn't take a dependency on the height of the parentCommandText
element, there's not necessarily a guarantee that element is the same height as the items of the list view
Using ListView::ContainerFromIndex() and casted into ListViewItem to get its ActualHeight
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.
As much as I hate this ternary, I'd rather get this in for now and file a follow-up PR to clean it up. Someone else on the team can override that opinion though. Thanks for your patience!
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.
Thanks for the contribution! This is great. I'm going to address my own comment about the App.xaml file and merge it.
src/cascadia/TerminalApp/App.xaml
Outdated
We need to manually create the error text brush as a | ||
theme-dependent brush. SystemControlErrorTextForegroundBrush | ||
is unfortunately static. | ||
--> |
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 totally understand why this file changed
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.
Yes. I don't either. Sorry for the mess.
This is excellent work. 😄 |
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Apologies, while this PR appears ready to be merged, it looks like |
🎉 Handy links: |
🎉 Handy links: |
Closes #7729