Skip to content

Commit 779cda8

Browse files
committed
add debug code & dismiss button
1 parent cc36b54 commit 779cda8

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

src/cascadia/TerminalApp/TerminalPage.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -2944,6 +2944,13 @@ namespace winrt::TerminalApp::implementation
29442944

29452945
void TerminalPage::_SearchMissingCommandHandler(const IInspectable /*sender*/, const winrt::Microsoft::Terminal::Control::SearchMissingCommandEventArgs args)
29462946
{
2947+
// If the user doesn't want to see this message again,
2948+
// don't even bother trying to search for the command
2949+
if (_IsMessageDismissed(InfoBarMessage::CommandNotFound))
2950+
{
2951+
return;
2952+
}
2953+
#if 0
29472954
static constexpr CLSID CLSID_PackageManager = { 0xC53A4F16, 0x787E, 0x42A4, 0xB3, 0x04, 0x29, 0xEF, 0xFB, 0x4B, 0xF5, 0x97 }; //C53A4F16-787E-42A4-B304-29EFFB4BF597
29482955
static constexpr CLSID CLSID_FindPackagesOptions = { 0x572DED96, 0x9C60, 0x4526, { 0x8F, 0x92, 0xEE, 0x7D, 0x91, 0xD3, 0x8C, 0x1A } }; //572DED96-9C60-4526-8F92-EE7D91D38C1A
29492956
static constexpr CLSID CLSID_PackageMatchFilter = { 0xD02C9DAF, 0x99DC, 0x429C, { 0xB5, 0x03, 0x4E, 0x50, 0x4E, 0x4A, 0xB0, 0x00 } }; //D02C9DAF-99DC-429C-B503-4E504E4AB000
@@ -3088,6 +3095,24 @@ namespace winrt::TerminalApp::implementation
30883095

30893096
ShowCommandNotFoundInfoBar(suggestions, footer);
30903097
}
3098+
#elif defined(DEBUG) || defined(_DEBUG) || defined(DBG)
3099+
const bool tooManySuggestions = false;
3100+
const std::wstring searchOption = L"command";
3101+
const std::wstring missingCmd = args.MissingCommand().data();
3102+
std::vector<std::wstring> pkgList = { L"pkg1", L"pkg2", L"pkg3" };
3103+
std::vector<std::wstring> suggestions;
3104+
suggestions.reserve(pkgList.size());
3105+
for (auto pkg : pkgList)
3106+
{
3107+
suggestions.emplace_back(fmt::format(L"winget install --id {}", pkg));
3108+
}
3109+
3110+
std::wstring footer = tooManySuggestions ?
3111+
fmt::format(L"winget search --{} {}", searchOption, missingCmd) :
3112+
L"";
3113+
3114+
ShowCommandNotFoundInfoBar(suggestions, footer);
3115+
#endif
30913116
}
30923117

30933118
winrt::fire_and_forget TerminalPage::ShowCommandNotFoundInfoBar(const std::vector<std::wstring> suggestions, std::wstring footerCmd)
@@ -4743,6 +4768,15 @@ namespace winrt::TerminalApp::implementation
47434768
}
47444769
}
47454770

4771+
void TerminalPage::_CommandNotFoundDismissHandler(const IInspectable& /*sender*/, const IInspectable& /*args*/) const
4772+
{
4773+
_DismissMessage(InfoBarMessage::CommandNotFound);
4774+
if (const auto infoBar = FindName(L"CommandNotFoundInfoBar").try_as<MUX::Controls::InfoBar>())
4775+
{
4776+
infoBar.IsOpen(false);
4777+
}
4778+
}
4779+
47464780
// Method Description:
47474781
// - Persists the user's choice not to show the information bar warning about "Windows Terminal can be set as your default terminal application"
47484782
// Then hides this information buffer.

src/cascadia/TerminalApp/TerminalPage.h

+1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ namespace winrt::TerminalApp::implementation
508508
winrt::fire_and_forget _ConnectionStateChangedHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args) const;
509509
void _CloseOnExitInfoDismissHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args) const;
510510
void _KeyboardServiceWarningInfoDismissHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args) const;
511+
void _CommandNotFoundDismissHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args) const;
511512
void _SetAsDefaultDismissHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
512513
void _SetAsDefaultOpenSettingsHandler(const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args);
513514
static bool _IsMessageDismissed(const winrt::Microsoft::Terminal::Settings::Model::InfoBarMessage& message);

src/cascadia/TerminalApp/TerminalPage.xaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,12 @@
7676
IsClosable="True"
7777
IsIconVisible="True"
7878
IsOpen="False"
79-
Severity="Error" />
79+
Severity="Error">
80+
<mux:InfoBar.ActionButton>
81+
<Button x:Uid="InfoBarDismissButton"
82+
Click="_CommandNotFoundDismissHandler" />
83+
</mux:InfoBar.ActionButton>
84+
</mux:InfoBar>
8085
</StackPanel>
8186

8287
<Grid x:Name="TabContent"

src/cascadia/TerminalSettingsModel/ApplicationState.idl

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Microsoft.Terminal.Settings.Model
1010
CloseOnExitInfo = 0,
1111
KeyboardServiceWarning,
1212
SetAsDefault,
13+
CommandNotFound
1314
};
1415

1516
runtimeclass WindowLayout

0 commit comments

Comments
 (0)