Compare commits
1 commit
main
...
dev/duhowt
Author | SHA1 | Date | |
---|---|---|---|
397a84e559 |
|
@ -886,17 +886,24 @@ namespace winrt::TerminalApp::implementation
|
|||
void CommandPalette::SetCommands(Collections::IVector<Command> const& actions)
|
||||
{
|
||||
_allCommands.Clear();
|
||||
for (const auto& action : actions)
|
||||
if (actions)
|
||||
{
|
||||
auto actionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action) };
|
||||
auto filteredCommand{ winrt::make<FilteredCommand>(actionPaletteItem) };
|
||||
_allCommands.Append(filteredCommand);
|
||||
for (const auto& action : actions)
|
||||
{
|
||||
auto actionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action) };
|
||||
auto filteredCommand{ winrt::make<FilteredCommand>(actionPaletteItem) };
|
||||
_allCommands.Append(filteredCommand);
|
||||
}
|
||||
}
|
||||
|
||||
if (Visibility() == Visibility::Visible && _currentMode == CommandPaletteMode::ActionMode)
|
||||
{
|
||||
_updateFilteredActions();
|
||||
_filterTextChanged(nullptr, nullptr);
|
||||
//_updateFilteredActions();
|
||||
}
|
||||
|
||||
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Loading" });
|
||||
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Loaded" });
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -1003,6 +1010,9 @@ namespace winrt::TerminalApp::implementation
|
|||
// clear + append when switching between modes.
|
||||
_filteredActions.Clear();
|
||||
_updateFilteredActions();
|
||||
|
||||
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Loading" });
|
||||
_PropertyChangedHandlers(*this, Windows::UI::Xaml::Data::PropertyChangedEventArgs{ L"Loaded" });
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
|
@ -47,6 +47,9 @@ namespace winrt::TerminalApp::implementation
|
|||
void EnableTabSwitcherMode(const uint32_t startIdx, Microsoft::Terminal::Settings::Model::TabSwitcherMode tabSwitcherMode);
|
||||
void EnableTabSearchMode();
|
||||
|
||||
bool Loading() const { return _currentMode == CommandPaletteMode::ActionMode && _allCommands.Size() == 0; }
|
||||
bool Loaded() const { return !Loading(); }
|
||||
|
||||
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
|
||||
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, NoMatchesText, _PropertyChangedHandlers);
|
||||
WINRT_OBSERVABLE_PROPERTY(winrt::hstring, SearchBoxPlaceholderText, _PropertyChangedHandlers);
|
||||
|
|
|
@ -19,6 +19,9 @@ namespace TerminalApp
|
|||
String ParentCommandName { get; };
|
||||
String ParsedCommandLineText { get; };
|
||||
|
||||
Boolean Loading { get; };
|
||||
Boolean Loaded { get; };
|
||||
|
||||
Windows.Foundation.Collections.IObservableVector<FilteredCommand> FilteredActions { get; };
|
||||
|
||||
void SetCommands(Windows.Foundation.Collections.IVector<Microsoft.Terminal.Settings.Model.Command> actions);
|
||||
|
|
|
@ -412,6 +412,7 @@
|
|||
Style="{ThemeResource CommandPaletteBackground}">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
|
@ -434,7 +435,7 @@
|
|||
Text="{x:Bind PrefixCharacter, Mode=OneWay}"
|
||||
Visibility="{x:Bind PrefixCharacter, Mode=OneWay, Converter={StaticResource ParentCommandVisibilityConverter}}" />
|
||||
|
||||
<StackPanel Grid.Row="1"
|
||||
<StackPanel Grid.Row="2"
|
||||
Padding="16,0,16,4"
|
||||
Orientation="Horizontal"
|
||||
Visibility="{x:Bind ParentCommandName, Mode=OneWay, Converter={StaticResource ParentCommandVisibilityConverter}}">
|
||||
|
@ -459,13 +460,13 @@
|
|||
</StackPanel>
|
||||
|
||||
<TextBlock x:Name="_noMatchesText"
|
||||
Grid.Row="1"
|
||||
Grid.Row="2"
|
||||
Padding="16"
|
||||
FontStyle="Italic"
|
||||
Text="{x:Bind NoMatchesText, Mode=OneWay}"
|
||||
Visibility="Collapsed" />
|
||||
|
||||
<Border Grid.Row="1"
|
||||
<Border Grid.Row="2"
|
||||
Padding="16"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
|
@ -481,7 +482,7 @@
|
|||
</Border>
|
||||
|
||||
<ListView x:Name="_filteredActionsView"
|
||||
Grid.Row="2"
|
||||
Grid.Row="3"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
AllowDrop="False"
|
||||
|
@ -491,7 +492,16 @@
|
|||
IsItemClickEnabled="True"
|
||||
ItemClick="_listItemClicked"
|
||||
ItemsSource="{x:Bind FilteredActions}"
|
||||
SelectionMode="Single" />
|
||||
SelectionMode="Single"
|
||||
Visibility="{x:Bind Loaded, Mode=OneWay}" />
|
||||
|
||||
<Grid Grid.Row="1"
|
||||
MinHeight="60"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="{x:Bind Loading, Mode=OneWay}">
|
||||
<mux:ProgressRing IsActive="{x:Bind Loading, Mode=OneWay}" />
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -107,8 +107,16 @@ winrt::fire_and_forget Jumplist::UpdateJumplist(const CascadiaSettings& settings
|
|||
{
|
||||
try
|
||||
{
|
||||
size_t i{};
|
||||
for (const auto& profile : profiles)
|
||||
{
|
||||
if (++i == 13)
|
||||
{
|
||||
// Only process the first 13 profiles.
|
||||
// Empirically observed as the limit for tasks in Windows 10
|
||||
break;
|
||||
}
|
||||
|
||||
// Craft the arguments following "wt.exe"
|
||||
auto args = fmt::format(L"-p {}", to_hstring(profile.Guid()));
|
||||
|
||||
|
|
|
@ -1950,13 +1950,28 @@ namespace winrt::TerminalApp::implementation
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TerminalPage::_UpdateCommandsForPalette()
|
||||
winrt::fire_and_forget TerminalPage::_UpdateCommandsForPalette()
|
||||
{
|
||||
IMap<winrt::hstring, Command> copyOfCommands = _ExpandCommands(_settings.GlobalSettings().ActionMap().NameMap(),
|
||||
_settings.ActiveProfiles().GetView(),
|
||||
_settings.GlobalSettings().ColorSchemes());
|
||||
auto settings{ _settings };
|
||||
CommandPalette().SetCommands(nullptr);
|
||||
|
||||
_recursiveUpdateCommandKeybindingLabels(_settings, copyOfCommands.GetView());
|
||||
co_await winrt::resume_background();
|
||||
|
||||
if (settings != _settings)
|
||||
{ // check before each expensive operation!
|
||||
co_return;
|
||||
}
|
||||
|
||||
IMap<winrt::hstring, Command> copyOfCommands = _ExpandCommands(settings.GlobalSettings().ActionMap().NameMap(),
|
||||
settings.ActiveProfiles().GetView(),
|
||||
settings.GlobalSettings().ColorSchemes());
|
||||
|
||||
if (settings != _settings)
|
||||
{ // check before each expensive operation!
|
||||
co_return;
|
||||
}
|
||||
|
||||
_recursiveUpdateCommandKeybindingLabels(settings, copyOfCommands.GetView());
|
||||
|
||||
// Update the command palette when settings reload
|
||||
auto commandsCollection = winrt::single_threaded_vector<Command>();
|
||||
|
@ -1965,6 +1980,13 @@ namespace winrt::TerminalApp::implementation
|
|||
commandsCollection.Append(nameAndCommand.Value());
|
||||
}
|
||||
|
||||
co_await winrt::resume_foreground(Dispatcher());
|
||||
|
||||
if (settings != _settings)
|
||||
{
|
||||
co_return;
|
||||
}
|
||||
|
||||
CommandPalette().SetCommands(commandsCollection);
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace winrt::TerminalApp::implementation
|
|||
void _UpdateTabIcon(TerminalTab& tab);
|
||||
void _UpdateTabView();
|
||||
void _UpdateTabWidthMode();
|
||||
void _UpdateCommandsForPalette();
|
||||
winrt::fire_and_forget _UpdateCommandsForPalette();
|
||||
|
||||
static winrt::Windows::Foundation::Collections::IMap<winrt::hstring, Microsoft::Terminal::Settings::Model::Command> _ExpandCommands(Windows::Foundation::Collections::IMapView<winrt::hstring, Microsoft::Terminal::Settings::Model::Command> commandsToExpand,
|
||||
Windows::Foundation::Collections::IVectorView<Microsoft::Terminal::Settings::Model::Profile> profiles,
|
||||
|
|
Loading…
Reference in a new issue