-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Move Tab Switcher mode handling into CommandPalette #8656
Conversation
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.
These are some smaller questions, nothing too major IMO
// Some callers might actually want smooth updating, like when the list | ||
// of tabs changes. |
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.
Does this mean that now, if a tab is removed which the switcher is open, that the entire list will re-animate into existence, rather than the smooth update it does now?
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.
Now if the tab is removed our ephemeral palette gets closed immediately 😊
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'm okay with this
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 believe that's because of the earlier change to dispatch bindings from TerminalPage::PreviewKeyDown, right? That makes sense to me.
But... does this also hold if a user (trying to break terminal :P) issues a sleep 5; exit
and then opens up the palette and waits for it to blow up?
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.
@DHowett - what a nasty user 😊 I believe that the problem you describe exists in the original code as well.
From my understanding, If the user triggers delayed sleep and then starts switching, what will happen right now is that we will still have TabPaletteItem populated in the switcher, but switching to it will have no action (as weak ref is empty). Not perfect, not terrible (or however they said this in Chernobyl). To resolve this we need to have the fully fledged binding that I planned for the next PR (where we do follow the changes in _tabs, _mruTabs that are observable collections).
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.
@DHowett - ignore the previous comment. What happens now, if the tab is closed by sleep 5; exit
we actually dismiss the switcher. This was introduced as a part of the ephemeral palette work (every change in tabs collection closes the palette) to ensure consistency. If the user tries to break terminal this way, the only impact that the palette gets closed.
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.
Okay this is better than before, esp for TabSearch - it reanimates less, which is good!
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.
Totally gonna sign off, but had a couple q outstanding. 😄 Thanks for cleaning up our command palette, @Don-Vito!
for (uint32_t index = 0; index < commandsToFilter.Size(); index++) | ||
{ | ||
actions.push_back(commandsToFilter.GetAt(index)); | ||
} |
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.
nit: is this transformable to a std::copy
with a back_inserter
? I remember Carlos and I had a similar discussion on the Settings editor UI
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.
@DHowett - semantically, yes 😊 Technically, I am not sure how to do it because commandsToFilter is an IVector. Is there a way to get the underlying vector / iterator for it?
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.
This works, but I have no idea why. VS won't tell me exactly where begin
and end
originate.
std::vector<winrt::hstring> vec{ L"One", L"Two", L"Three" };
auto f = winrt::single_threaded_vector(std::move(vec));
Collections::IVector<winrt::hstring> projectedVector{ f };
std::for_each(begin(projectedVector), end(projectedVector), [](auto&& val) {
std::wcout << std::wstring_view{ val } << L"\n";
});
I'm not using namespace winrt::impl
, but here we are in 2021 and all signs point to that I am using begin/end directly out of winrt::impl
.
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.
This is absolutely cool! Is it documented somewhere? 😄
So begin and end are a part of Windows.Foundations.Collections.h - nice!
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 far as I can tell, it's a language feature (!) that in part is used to support range-based for loops. I've been digging for documentation (and trying to figure out how it works), but it has been difficult.
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.
C:\Users...\Documents\GitHub\terminal\src\cascadia\TerminalApp\Generated Files\winrt\Windows.Foundation.Collections.h
template <typename T, std::enable_if_t<has_GetAt<T>::value, int> = 0>
fast_iterator<T> begin(T const& collection) noexcept
{
return { collection, 0 };
}
template <typename T, std::enable_if_t<has_GetAt<T>::value, int> = 0>
fast_iterator<T> end(T const& collection)
{
return { collection, collection.Size() };
}
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.
Right, but if nobody is using namespace winrt::impl
(which they tell us is private 😉), those definitions shouldn't be found when they're not namespace-qualified. Yet this works.
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.
Got it! This is clever. Argument-dependent lookup (ADL) specifies how free functions are resolved (based on their argument types). One of the steps in argument-dependent lookup is the collection of the class hierarchy and the namespaces of the classes in that hierarchy.
Because each C++/WinRT projection type inherits from something in winrt::impl
, ADL on projection types finds any free functions inside the impl
namespace. If they didn't inherit from winrt::impl
, winrt::impl::begin
would not be found.
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.
This is really clever.. but it also makes the modern c++ extremely challenging to code review IMHO.
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.
Since the command palette doesn't observe the vector passed in to SetTabs, we could weaken the contract to IVector<TabBase>
from IObservableVector<TabBase>
and undo the changes in TerminalPage that make _mruTab
observable. I'm not blocking on this, but if you want to do it I'll be holding off the merge 😄
@msftbot merge this in 24 hours |
Hello @DHowett! Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:
If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you". |
@DHowett - this is actually a preparation. I am going to submit a PR, where cmdpal observes these collections (and we will set them only once). This will be a next step towards filterable list view |
🎉 Handy links: |
A part of the microsoft#8415. Includes: * Moving `TabSwitcherMode` related decisions into `CommandPalette` (simplifying the logic of `TerminalPage::SelectNextTab`) * Fix a bug where the index of first tab switch is incorrect (since bindings are not updated) * Removing redundant `CommandPalette` updates * Preparations for tabs binding
A part of the #8415.
Includes:
TabSwitcherMode
related decisions intoCommandPalette
(simplifying the logic of
TerminalPage::SelectNextTab
)(since bindings are not updated)
CommandPalette
updates