Skip to content
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

Add action for Quick Fix and key binding for Suggestions #17502

Merged
merged 9 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,8 +1599,8 @@ namespace winrt::TerminalApp::implementation
{
if (const auto& control{ _GetActiveControl() })
{
control.OpenQuickFixMenu();
const auto handled = control.OpenQuickFixMenu();
args.Handled(handled);
}
args.Handled(true);
}
}
28 changes: 18 additions & 10 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
}
});
if constexpr (Feature_QuickFix::IsEnabled())
{
QuickFixMenu().Closed([weakThis = get_weak()](auto&&, auto&&) {
if (auto control{ weakThis.get() }; control && !control->_IsClosing())
{
// Expand the quick fix button if it's collapsed (looks nicer)
if (control->_quickFixButtonCollapsible)
{
VisualStateManager::GoToState(*control, StateCollapsed, false);
}
}
});
}
}

void TermControl::_QuickFixButton_PointerEntered(const IInspectable& /*sender*/, const PointerRoutedEventArgs& /*e*/)
Expand Down Expand Up @@ -3555,8 +3568,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation

if (Feature_QuickFix::IsEnabled())
{
auto quickFixBtn = FindName(L"QuickFixButton").as<Controls::Button>();
quickFixBtn.Height(args.Height() / dpiScale);
QuickFixButton().Height(args.Height() / dpiScale);
QuickFixIcon().FontSize(static_cast<double>(args.Width() / dpiScale));
RefreshQuickFixMenu();
}
Expand Down Expand Up @@ -3892,24 +3904,20 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return std::max(CharacterDimensions().Width * 2.0 / 3.0, GetPadding().Left);
}

void TermControl::OpenQuickFixMenu()
bool TermControl::OpenQuickFixMenu()
{
if (Feature_QuickFix::IsEnabled() && _core.QuickFixesAvailable())
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
{
// Expand the quick fix button if it's collapsed (looks nicer)
if (_quickFixButtonCollapsible)
{
VisualStateManager::GoToState(*this, StateNormal, false);
QuickFixButton().Flyout().Closing([weakThis = get_weak()](auto& /*sender*/, auto& /*args*/) {
if (auto termCtrl = weakThis.get())
{
VisualStateManager::GoToState(*termCtrl, StateCollapsed, false);
}
});
}
auto quickFixBtn = QuickFixButton();
quickFixBtn.Flyout().ShowAt(quickFixBtn);
return true;
}
return false;
}

void TermControl::RefreshQuickFixMenu()
Expand All @@ -3919,7 +3927,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}

auto quickFixBtn = FindName(L"QuickFixButton").as<Controls::Button>();
auto quickFixBtn = QuickFixButton();
if (!_core.QuickFixesAvailable())
{
quickFixBtn.Visibility(Visibility::Collapsed);
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void RawWriteString(const winrt::hstring& text);

void ShowContextMenu();
void OpenQuickFixMenu();
bool OpenQuickFixMenu();
void RefreshQuickFixMenu();
void ClearQuickFix();

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/TermControl.idl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ namespace Microsoft.Terminal.Control
Double QuickFixButtonCollapsedWidth { get; };

void ShowContextMenu();
void OpenQuickFixMenu();
Boolean OpenQuickFixMenu();
void RefreshQuickFixMenu();
void ClearQuickFix();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,6 @@
<value>Save Snippet</value>
</data>
<data name="QuickFixCommandKey" xml:space="preserve">
<value>Quick fix</value>
<value>Open quick fix menu</value>
</data>
</root>
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsModel/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@
{ "command": "restoreLastClosed", "id": "Terminal.RestoreLastClosed" },
{ "command": "openAbout", "id": "Terminal.OpenAboutDialog" },
{ "command": "experimental.openTasks", "id": "Terminal.OpenTasks" },
{ "command": "quickFix", "id": "Terminal.QuickFix" },
carlos-zamora marked this conversation as resolved.
Show resolved Hide resolved
{ "command": { "action": "showSuggestions", "source": "all"}, "id": "Terminal.Suggestions" },

// Tab Management
Expand Down
Loading