Skip to content

Commit

Permalink
Add a keybinding for Quick Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-zamora committed Jul 12, 2024
1 parent 8c6eaad commit d88389c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/cascadia/TerminalApp/AppActionHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1593,4 +1593,14 @@ namespace winrt::TerminalApp::implementation
_ShowAboutDialog();
args.Handled(true);
}

void TerminalPage::_HandleQuickFix(const IInspectable& /*sender*/,
const ActionEventArgs& args)
{
if (const auto& control{ _GetActiveControl() })
{
control.OpenQuickFixMenu();
}
args.Handled(true);
}
}
8 changes: 8 additions & 0 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3892,6 +3892,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return std::max(CharacterDimensions().Width * 2.0 / 3.0, GetPadding().Left);
}

void TermControl::OpenQuickFixMenu()
{
if (Feature_QuickFix::IsEnabled() && _core.QuickFixesAvailable())
{
QuickFixButton().Flyout().ShowAt(QuickFixButton());
}
}

void TermControl::RefreshQuickFixMenu()
{
if (!Feature_QuickFix::IsEnabled())
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void RawWriteString(const winrt::hstring& text);

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

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

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

Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalSettingsModel/ActionAndArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static constexpr std::string_view RestartConnectionKey{ "restartConnection" };
static constexpr std::string_view ToggleBroadcastInputKey{ "toggleBroadcastInput" };
static constexpr std::string_view OpenScratchpadKey{ "experimental.openScratchpad" };
static constexpr std::string_view OpenAboutKey{ "openAbout" };
static constexpr std::string_view QuickFixKey{ "quickFix" };

static constexpr std::string_view ActionKey{ "action" };

Expand Down Expand Up @@ -438,6 +439,7 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation
{ ShortcutAction::ToggleBroadcastInput, RS_(L"ToggleBroadcastInputCommandKey") },
{ ShortcutAction::OpenScratchpad, RS_(L"OpenScratchpadKey") },
{ ShortcutAction::OpenAbout, RS_(L"OpenAboutCommandKey") },
{ ShortcutAction::QuickFix, RS_(L"QuickFixCommandKey") },
};
}();

Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalSettingsModel/AllShortcutActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
ON_ALL_ACTIONS(RestartConnection) \
ON_ALL_ACTIONS(ToggleBroadcastInput) \
ON_ALL_ACTIONS(OpenScratchpad) \
ON_ALL_ACTIONS(OpenAbout)
ON_ALL_ACTIONS(OpenAbout) \
ON_ALL_ACTIONS(QuickFix)

#define ALL_SHORTCUT_ACTIONS_WITH_ARGS \
ON_ALL_ACTIONS_WITH_ARGS(AdjustFontSize) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,4 +734,7 @@
<data name="SaveSnippetNamePrefix" xml:space="preserve">
<value>Save Snippet</value>
</data>
<data name="QuickFixCommandKey" xml:space="preserve">
<value>Quick fix</value>
</data>
</root>
2 changes: 2 additions & 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" },

// Tab Management
// "command": "closeTab" is unbound by default.
Expand Down Expand Up @@ -639,6 +640,7 @@
{ "keys":"ctrl+shift+p", "id": "Terminal.ToggleCommandPalette" },
{ "keys":"win+sc(41)", "id": "Terminal.QuakeMode" },
{ "keys": "alt+space", "id": "Terminal.OpenSystemMenu" },
{ "keys": "ctrl+period", "id": "Terminal.QuickFix" },

// Tab Management
// "command": "closeTab" is unbound by default.
Expand Down

0 comments on commit d88389c

Please sign in to comment.