-
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 NextSearchMatch and PreviouSearchMatch actions #8522
Changes from all commits
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 |
---|---|---|
|
@@ -224,6 +224,26 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation | |
} | ||
} | ||
|
||
void TermControl::SearchNextMatch() | ||
{ | ||
if (!_searchBox) | ||
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. @Hegunumo, @zadjii-msft - product question: if the search box is collapsed and we invoke "search next" binding, shouldn't we open a search box and try to search with the last needle (if exists)? 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. |
||
{ | ||
return; | ||
} | ||
keyBindingSearch = true; | ||
_Search(_searchBox->TextBox().Text(), true, false); | ||
} | ||
|
||
void TermControl::SearchPrevMatch() | ||
{ | ||
if (!_searchBox) | ||
{ | ||
return; | ||
} | ||
keyBindingSearch = true; | ||
_Search(_searchBox->TextBox().Text(), false, false); | ||
} | ||
|
||
// Method Description: | ||
// - Search text in text buffer. This is triggered if the user click | ||
// search button or press enter. | ||
|
@@ -938,10 +958,21 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation | |
|
||
void TermControl::_KeyHandler(Input::KeyRoutedEventArgs const& e, const bool keyDown) | ||
{ | ||
if (e.OriginalKey() == VirtualKey::Enter) | ||
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. Can you please document here why aren't we handling Enter in the terminal control? I guess it works, but I am not sure why 😊 |
||
{ | ||
return; | ||
} | ||
Comment on lines
+961
to
+964
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. Why is this needed? |
||
|
||
// If the current focused element is a child element of searchbox, | ||
// we do not send this event up to terminal | ||
if (_searchBox && _searchBox->ContainsFocus()) | ||
if (_searchBox && _searchBox->ContainsFocus() && _searchBox->TextBox().Text().empty()) | ||
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. Why 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. Please update the documentation of the condition as you have restricted it. Here as well I am not sure I understand why do we need the restriction. I mean now if the key event got here but the searchbox is focused are we sure it is OK to proceed? Cannot it result with sending a character to a terminal? Optimally we don't need to check the |
||
{ | ||
return; | ||
} | ||
|
||
if (keyBindingSearch) | ||
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. Can you please document your logic here as well? If we searched with key binding then we should ignore the next key? 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. Curious. If we use the keybinding to invoke this action, then on the keyDown, we'll select the text. Then on the key_up_, we'll dismiss the selection. 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. Okay this is definitely tricky, and I don't know what a good solution is. The action is either invoked:
So if it happened on a keydown, we do need to not dismiss the selection on the next keyup. Weird. I wonder how this worked in the keyboard-selection implementation. Wouldn't that have hit the same problem? Paging @carlos-zamora to see if he can here. Am I just being daft? Is there an obvious way to create a selection via action and have it not dismiss on the keyup? 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. Derp. I can't read. We need to do this for #3758 so I'm just gonna do it here anyways |
||
{ | ||
keyBindingSearch = false; | ||
return; | ||
} | ||
Comment on lines
+973
to
977
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 feels wrong to me. I know currently, actions are only triggerable with the keyboard, but theoretically, they might be invokable through other UI elements. Are we just trying to prevent the keys from being duplicated here? |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,6 +285,8 @@ | |
{ "command": "openSettings", "keys": "ctrl+," }, | ||
{ "command": { "action": "openSettings", "target": "defaultsFile" }, "keys": "ctrl+alt+," }, | ||
{ "command": "find", "keys": "ctrl+shift+f" }, | ||
{ "command": "nextSearchMatchKey", "keys": "ctrl+shift+n" }, | ||
{ "command": "prevSearchMatchKey", "keys": "ctrl+shift+k" }, | ||
Comment on lines
+288
to
+289
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. I'm not sure how the team feels about adding these to the default keybindings - @DHowett thoughts? |
||
{ "command": "toggleShaderEffects" }, | ||
{ "command": "openTabColorPicker" }, | ||
{ "command": "renameTab" }, | ||
|
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.
Should these be
to make sure
termControl
isn't null?