-
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
Add action for Quick Fix and key binding for Suggestions #17502
Conversation
@@ -637,6 +638,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" }, |
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.
The
quickFix
action is bound toctrl+period
by default to align with VS' "quick actions" feature and VS Code's "quick fix" feature.
@zadjii-msft funny enough, I feel like openSuggestions
would be better suited here. Especially since the suggestions UI loads quick fixes automatically. Maybe we want ctrl+period to be used for openSuggestions instead?
Also, we're in a weird spot rn. Quick fixes are behind a feature flag so idk if it makes sense to bind this just yet. Happy to remove changes to this file, just want some clarity on the plan here.
CC @DHowett
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.
hard veto binding just ctrl+anything
. Ctrl alone is reserved for a modifier for the CLI application to use.
I'm probably biased, so I probably need to recuse myself from answering if it should be quickFix
or showSuggestions
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.
(In case you're curious) Found that "ctrl+period" is used for "repeat the last command" in nano, so yeah, we need a different keybinding.
Changed to "ctrl+shift+period".
The questions above still stand though. How about long-term we do...
- ctrl+shift+period --> quick fix
- alt+shift+period --> suggestions
Just wanna make sure I don't claim a keybinding you were planning to claim later.
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.
Discussed a bit during today's bug bash. Here's the leading proposal rn:
- default kbd opens suggestions UI (source=all)
- clicking QF button --> open suggestions UI
As we add more quick fixes (i.e. actual winget suggestions, non-snippets, etc.) and non-snippet suggestions, we can revisit this and change it.
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.
(Aside from the question in your comment, LGTM.)
@@ -637,6 +638,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" }, |
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.
hard veto binding just ctrl+anything
. Ctrl alone is reserved for a modifier for the CLI application to use.
I'm probably biased, so I probably need to recuse myself from answering if it should be quickFix
or showSuggestions
Quick Fix feedback from bug bash
|
1553641
to
40d7d1e
Compare
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.
I'll approve but maybe we swap that action around in post
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.
2/9
I'm bumping this from the merge queue - it took me all of four seconds to find a resource leak 😄 |
@@ -3920,7 +3940,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
const auto viewportBufferPosition = rd->GetViewport(); | |||
const auto cursorBufferPosition = rd->GetCursorPosition(); | |||
rd->UnlockConsole(); | |||
if (cursorBufferPosition.y < viewportBufferPosition.Top() || cursorBufferPosition.y > viewportBufferPosition.BottomExclusive()) | |||
if (cursorBufferPosition.y < viewportBufferPosition.Top() || cursorBufferPosition.y > viewportBufferPosition.BottomInclusive()) |
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.
what's this change do?
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 is an extension of the fix for scrolling may result in the button being drawn in the wrong place
.
From some testing, there were some scenarios where the button would be drawn on the bottom left corner of the terminal. The "last visible line of text" would be cut off by the window, so the renderer wouldn't draw the text. But XAML would still draw the button. This didn't seem right to me, so I made this change.
@@ -1597,12 +1597,13 @@ void Terminal::ColorSelection(const TextAttribute& attr, winrt::Microsoft::Termi | |||
} | |||
|
|||
// Method Description: | |||
// - Returns the position of the cursor relative to the active viewport | |||
// - Returns the position of the cursor relative to the visible viewport | |||
til::point Terminal::GetViewportRelativeCursorPosition() const noexcept |
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.
who else uses this, and are they impacted by this change?
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.
Already did the research. 😉 Here's the relevant stuff from the PR body:
- scrolling may result in the button being drawn in the wrong place
- The bug was tracked down this line:
TermControl::CursorPositionInDips()
-->_core.CursorPosition()
-->Terminal::GetViewportRelativeCursorPosition()
. The mutable viewport there does not update when the user scrolls. Thus, the button would be drawn on the same position on the screen even though we scrolled. To fix this, I include the_scrollOffset
in the calculation. The only other place this function is used is with the suggestions UI, which does not update the UIs position as we scroll (but if we're interested in doing that, we can now).
src/cascadia/TerminalSettingsModel/Resources/en-US/Resources.resw
Outdated
Show resolved
Hide resolved
Scrolling behavior:
I removed this from the commit message because individual commits inside a PR get destroyed when it is squashed. |
Adds a keybinding to open the quick fix menu, if one is available. When the action is used, we also open up the button (if it was collapsed) because that looks nice.
The
showSuggestions
action is bound toctrl+shift+period
by default to align with VS' "quick actions" feature and VS Code's "quick fix" feature. This was chosen over binding toquickFix
because it's more helpful. The quick fix button is a route for users that prefer to use the mouse. If users want to add a keybinding to activate thequickFix
button, they can do that now.This PR also performs a bit of miscellaneous polish from the bug bash. This includes:
TermControl::CursorPositionInDips()
-->_core.CursorPosition()
-->Terminal::GetViewportRelativeCursorPosition()
. The mutable viewport there does not update when the user scrolls. Thus, the button would be drawn on the same position on the screen even though we scrolled. To fix this, I include the_scrollOffset
in the calculation. The only other place this function is used is with the suggestions UI, which does not update the UIs position as we scroll (but if we're interested in doing that, we can now).Closes #17377