-
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
Introduce parsed command line text to command palette #8515
Changes from 3 commits
7d6c61a
e0739c2
dc33d61
4ceeadf
a39dc0d
39553a3
75fffb3
dc24592
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
#include "pch.h" | ||
#include "CommandPalette.h" | ||
|
||
#include "AppCommandlineArgs.h" | ||
#include <LibraryResources.h> | ||
|
||
#include "CommandPalette.g.cpp" | ||
|
@@ -733,6 +733,38 @@ namespace winrt::TerminalApp::implementation | |
{ | ||
_noMatchesText().Visibility(Visibility::Collapsed); | ||
} | ||
|
||
if (_currentMode == CommandPaletteMode::CommandlineMode) | ||
{ | ||
ParsedCommandLineText(L""); | ||
|
||
const auto commandLine = _getTrimmedInput(); | ||
if (!commandLine.empty()) | ||
{ | ||
ExecuteCommandlineArgs args{ commandLine }; | ||
::TerminalApp::AppCommandlineArgs appArgs; | ||
appArgs.DisableHelpInExitMessage(); | ||
|
||
if (appArgs.ParseArgs(args) == 0) | ||
{ | ||
const auto& commands = appArgs.GetStartupActions(); | ||
if (commands.size() > 0) | ||
{ | ||
std::wstring commandDescription{ RS_(L"CommandPalette_ParsedCommandLine") + L":" }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (asking the team) Not too familiar with how localization works, but should we move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DHowett would know for sure, but my guess would be yes, we need to move it to the resw. I'm thinking the resource would need to be
and then we There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do agree that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I actually agree with that. We may want the actions to each be a separate run of text for whatever reason. |
||
for (const auto& command : commands) | ||
{ | ||
commandDescription += L"\n\t" + command.Args().GenerateName(); | ||
} | ||
ParsedCommandLineText(commandDescription.data()); | ||
} | ||
} | ||
else | ||
{ | ||
ParsedCommandLineText(RS_(L"CommandPalette_FailedParsingCommandLine") + L":\n\t" + til::u8u16(appArgs.GetExitMessage())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same down here, we should use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
} | ||
_noMatchesText().Visibility(Visibility::Visible); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious -- we're showing the no matches string all the time now? What's this look like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DHowett - I am afraid this might be a leftover.. 🤦 which is hidden by the ParsedCommandLineText... 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep. It is a leftover. Thanks! |
||
} | ||
} | ||
} | ||
|
||
void CommandPalette::_evaluatePrefix() | ||
|
@@ -837,6 +869,7 @@ namespace winrt::TerminalApp::implementation | |
} | ||
} | ||
|
||
ParsedCommandLineText(L""); | ||
_searchBox().Text(L""); | ||
_searchBox().Select(_searchBox().Text().size(), 0); | ||
// Leaving this block of code outside the above if-statement | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ the MIT License. See LICENSE in the project root for license information. --> | |
|
||
<!-- This creates an instance of our CommandKeyChordVisibilityConverter we can reference below --> | ||
<local:EmptyStringVisibilityConverter x:Key="CommandKeyChordVisibilityConverter"/> | ||
<local:EmptyStringVisibilityConverter x:Key="ParsedCommandLineTextVisibilityConverter"/> | ||
<local:EmptyStringVisibilityConverter x:Key="ParentCommandVisibilityConverter"/> | ||
<local:HasNestedCommandsVisibilityConverter x:Key="HasNestedCommandsVisibilityConverter"/> | ||
<local:IconPathConverter x:Key="IconSourceConverter"/> | ||
|
@@ -67,6 +68,16 @@ the MIT License. See LICENSE in the project root for license information. --> | |
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" /> | ||
</Style> | ||
|
||
<!-- ParsedCommandLineText styles --> | ||
<Style x:Key="ParsedCommandLineBorderStyle" TargetType="Border"> | ||
<Setter Property="BorderThickness" Value="1" /> | ||
<Setter Property="CornerRadius" Value="1" /> | ||
<Setter Property="Background" Value="{ThemeResource SystemAltMediumLowColor}" /> | ||
<Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" /> | ||
</Style> | ||
<Style x:Key="ParsedCommandLineTextBlockStyle" TargetType="TextBlock"> | ||
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="Light"> | ||
<Style x:Key="CommandPaletteBackground" TargetType="Grid"> | ||
|
@@ -98,6 +109,16 @@ the MIT License. See LICENSE in the project root for license information. --> | |
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" /> | ||
</Style> | ||
|
||
<!-- ParsedCommandLineText styles --> | ||
<Style x:Key="ParsedCommandLineBorderStyle" TargetType="Border"> | ||
<Setter Property="BorderThickness" Value="1" /> | ||
<Setter Property="CornerRadius" Value="1" /> | ||
<Setter Property="Background" Value="{ThemeResource SystemAltMediumLowColor}" /> | ||
<Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" /> | ||
</Style> | ||
<Style x:Key="ParsedCommandLineTextBlockStyle" TargetType="TextBlock"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spacing looks strange around here.. Sup? |
||
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseMediumBrush}" /> | ||
</Style> | ||
</ResourceDictionary> | ||
<ResourceDictionary x:Key="HighContrast"> | ||
<Style x:Key="CommandPaletteBackground" TargetType="Grid"> | ||
|
@@ -108,6 +129,9 @@ the MIT License. See LICENSE in the project root for license information. --> | |
<Style x:Key="KeyChordBorderStyle" TargetType="Border"/> | ||
<Style x:Key="KeyChordTextBlockStyle" TargetType="TextBlock"/> | ||
|
||
<!-- ParsedCommandLineText styles (use XAML defaults for High Contrast theme) --> | ||
<Style x:Key="ParsedCommandLineBoderStyle" TargetType="Border"/> | ||
<Style x:Key="ParsedCommandLineTextBlockStyle" TargetType="TextBlock"/> | ||
</ResourceDictionary> | ||
</ResourceDictionary.ThemeDictionaries> | ||
</ResourceDictionary> | ||
|
@@ -226,6 +250,20 @@ the MIT License. See LICENSE in the project root for license information. --> | |
Text="{x:Bind NoMatchesText, Mode=OneWay}"> | ||
</TextBlock> | ||
|
||
<Border | ||
Grid.Row="1" | ||
Visibility="{x:Bind ParsedCommandLineText, Mode=OneWay, Converter={StaticResource ParsedCommandLineTextVisibilityConverter}}" | ||
Style="{ThemeResource ParsedCommandLineBorderStyle}" | ||
Padding="16" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Center"> | ||
|
||
<TextBlock | ||
FontStyle="Italic" | ||
TextWrapping="Wrap" | ||
Text="{x:Bind ParsedCommandLineText, Mode=OneWay}"/> | ||
</Border> | ||
|
||
<ListView | ||
Grid.Row="2" | ||
x:Name="_filteredActionsView" | ||
|
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.
Part of me wonders if the CommandPalette should just keep a single
AppCommandlineArgs
instance as a member, and then reset it and re-use it for parsing each time.That being said, this solution certainly does work
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.
@zadjii-msft - I see your point. I allowed this to myself, since today we do allocate an instance upon every execution. However, now we will actually allocate an instance on every character in the search - so it makes sense to cache it. I will see if there is a good way to reset the instance - since the internal reset we have there now is partial IIRC.