Repository navigation
Move Tab Switcher mode handling into CommandPalette - #8656
4 commits merged into
Conversation
Mike Griese (zadjii-msft)
left a comment
There was a problem hiding this comment.
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.
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.
Now if the tab is removed our ephemeral palette gets closed immediately 😊
There was a problem hiding this comment.
I'm okay with this
There was a problem hiding this comment.
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.
Dustin L. Howett (@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.
Dustin L. Howett (@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.
Mike Griese (zadjii-msft)
left a comment
There was a problem hiding this comment.
Okay this is better than before, esp for TabSearch - it reanimates less, which is good!
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
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.
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.
Dustin L. Howett (@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.
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.
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.
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.
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.
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.
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.
This is really clever.. but it also makes the modern c++ extremely challenging to code review IMHO.
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
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 Dustin L. Howett (@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". |
Dustin L. Howett (@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:
TabSwitcherModerelated decisions intoCommandPalette(simplifying the logic of
TerminalPage::SelectNextTab)(since bindings are not updated)
CommandPaletteupdates