-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Add Quick Fix UI and support for custom CommandNotFound OSC #16848
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
Changes from 21 commits
12100c5
c8d13d4
534c2d9
c1e1eab
68ed03d
c2417bb
6a361ef
a2e57b4
cfaa09d
88b64cd
48a36be
d8c8807
8c0d7c6
ec1fbc2
767692c
d4b6904
4e5d07d
27d464c
0f801a9
a545325
755f121
a0aa2d0
1ffbae1
0c5d880
ef6af81
db7f464
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 |
---|---|---|
|
@@ -110,6 +110,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
auto pfnCompletionsChanged = [=](auto&& menuJson, auto&& replaceLength) { _terminalCompletionsChanged(menuJson, replaceLength); }; | ||
_terminal->CompletionsChangedCallback(pfnCompletionsChanged); | ||
|
||
auto pfnSearchMissingCommand = [this](auto&& PH1) { _terminalSearchMissingCommand(std::forward<decltype(PH1)>(PH1)); }; | ||
_terminal->SetSearchMissingCommandCallback(pfnSearchMissingCommand); | ||
|
||
auto pfnClearQuickFix = [this] { ClearQuickFix(); }; | ||
_terminal->SetClearQuickFixCallback(pfnClearQuickFix); | ||
|
||
// MSFT 33353327: Initialize the renderer in the ctor instead of Initialize(). | ||
// We need the renderer to be ready to accept new engines before the SwapChainPanel is ready to go. | ||
// If we wait, a screen reader may try to get the AutomationPeer (aka the UIA Engine), and we won't be able to attach | ||
|
@@ -1609,6 +1615,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
_midiAudio.PlayNote(reinterpret_cast<HWND>(_owningHwnd), noteNumber, velocity, std::chrono::duration_cast<std::chrono::milliseconds>(duration)); | ||
} | ||
|
||
void ControlCore::_terminalSearchMissingCommand(std::wstring_view missingCommand) | ||
{ | ||
SearchMissingCommand.raise(*this, make<implementation::SearchMissingCommandEventArgs>(hstring{ missingCommand })); | ||
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. 📝 this goes up on the BG thread, then comes back down into us in |
||
} | ||
|
||
void ControlCore::ClearQuickFix() | ||
{ | ||
_cachedQuickFixes = nullptr; | ||
RefreshQuickFixUI.raise(*this, nullptr); | ||
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. mildly alarmed that ClearQuickFix seems to refresh the QF UI but |
||
} | ||
|
||
bool ControlCore::HasSelection() const | ||
{ | ||
const auto lock = _terminal->LockForReading(); | ||
|
@@ -2279,9 +2296,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
|
||
auto context = winrt::make_self<CommandHistoryContext>(std::move(commands)); | ||
context->CurrentCommandline(trimmedCurrentCommand); | ||
context->QuickFixes(_cachedQuickFixes); | ||
return *context; | ||
} | ||
|
||
bool ControlCore::QuickFixesAvailable() const noexcept | ||
{ | ||
return _cachedQuickFixes && _cachedQuickFixes.Size() > 0; | ||
} | ||
|
||
void ControlCore::UpdateQuickFixes(const Windows::Foundation::Collections::IVector<hstring>& quickFixes) | ||
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. this is more of a |
||
{ | ||
_cachedQuickFixes = quickFixes; | ||
} | ||
|
||
Core::Scheme ControlCore::ColorScheme() const noexcept | ||
{ | ||
Core::Scheme s; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,8 +68,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
{ | ||
til::property<Windows::Foundation::Collections::IVector<winrt::hstring>> History; | ||
til::property<winrt::hstring> CurrentCommandline; | ||
til::property<Windows::Foundation::Collections::IVector<winrt::hstring>> QuickFixes; | ||
carlos-zamora marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
CommandHistoryContext(std::vector<winrt::hstring>&& history) | ||
CommandHistoryContext(std::vector<winrt::hstring>&& history) : | ||
QuickFixes(winrt::single_threaded_vector<winrt::hstring>()) | ||
{ | ||
History(winrt::single_threaded_vector<winrt::hstring>(std::move(history))); | ||
} | ||
|
@@ -153,6 +155,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
void PersistToPath(const wchar_t* path) const; | ||
void RestoreFromPath(const wchar_t* path) const; | ||
|
||
void ClearQuickFix(); | ||
|
||
#pragma region ICoreState | ||
const size_t TaskbarState() const noexcept; | ||
const size_t TaskbarProgress() const noexcept; | ||
|
@@ -241,6 +245,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
|
||
hstring ReadEntireBuffer() const; | ||
Control::CommandHistoryContext CommandHistory() const; | ||
bool QuickFixesAvailable() const noexcept; | ||
void UpdateQuickFixes(const Windows::Foundation::Collections::IVector<hstring>& quickFixes); | ||
|
||
void AdjustOpacity(const float opacity, const bool relative); | ||
|
||
|
@@ -283,6 +289,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
til::typed_event<IInspectable, Control::UpdateSelectionMarkersEventArgs> UpdateSelectionMarkers; | ||
til::typed_event<IInspectable, Control::OpenHyperlinkEventArgs> OpenHyperlink; | ||
til::typed_event<IInspectable, Control::CompletionsChangedEventArgs> CompletionsChanged; | ||
til::typed_event<IInspectable, Control::SearchMissingCommandEventArgs> SearchMissingCommand; | ||
til::typed_event<> RefreshQuickFixUI; | ||
|
||
til::typed_event<> CloseTerminalRequested; | ||
til::typed_event<> RestartTerminalRequested; | ||
|
@@ -352,6 +360,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
|
||
til::point _contextMenuBufferPosition{ 0, 0 }; | ||
|
||
Windows::Foundation::Collections::IVector<int32_t> _cachedSearchResultRows{ nullptr }; | ||
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. what is this? 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. it looks like a line that was removed in #17132. bad conflict resolution?
DHowett marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Windows::Foundation::Collections::IVector<hstring> _cachedQuickFixes{ nullptr }; | ||
|
||
void _setupDispatcherAndCallbacks(); | ||
|
||
bool _setFontSizeUnderLock(float fontSize); | ||
|
@@ -375,6 +386,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
void _terminalPlayMidiNote(const int noteNumber, | ||
const int velocity, | ||
const std::chrono::microseconds duration); | ||
void _terminalSearchMissingCommand(std::wstring_view missingCommand); | ||
|
||
winrt::fire_and_forget _terminalCompletionsChanged(std::wstring_view menuJson, unsigned int replaceLength); | ||
|
||
|
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 doesn't actually do the winget lookup for
args.MissingCommand
, but we are including the winget winmd?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.
Oops. Yeah, we're blocked by winget. Internally tracking here.
Removed any references to the WinMD since we're not actually using it.