-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e48a45
commit ba375ec
Showing
17 changed files
with
48 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -950,21 +950,27 @@ namespace winrt::TerminalApp::implementation | |
void CommandPalette::SetActionMap(const Microsoft::Terminal::Settings::Model::IActionMapView& actionMap) | ||
{ | ||
_actionMap = actionMap; | ||
_setCommands(); | ||
} | ||
|
||
void CommandPalette::SetCommands(const Collections::IVector<Command>& actions) | ||
void CommandPalette::_setCommands() | ||
{ | ||
_allCommands.Clear(); | ||
for (const auto& action : actions) | ||
if (_actionMap) | ||
{ | ||
auto actionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action) }; | ||
auto filteredCommand{ winrt::make<FilteredCommand>(actionPaletteItem) }; | ||
_allCommands.Append(filteredCommand); | ||
} | ||
_allCommands.Clear(); | ||
const auto expandedCommands{ _actionMap.ExpandedCommands() }; | ||
for (const auto& action : expandedCommands) | ||
{ | ||
const auto keyChordText{ KeyChordSerialization::ToString(_actionMap.GetKeyBindingForAction(action.ID())) }; | ||
auto actionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action, keyChordText) }; | ||
auto filteredCommand{ winrt::make<FilteredCommand>(actionPaletteItem) }; | ||
_allCommands.Append(filteredCommand); | ||
} | ||
|
||
if (Visibility() == Visibility::Visible && _currentMode == CommandPaletteMode::ActionMode) | ||
{ | ||
_updateFilteredActions(); | ||
if (Visibility() == Visibility::Visible && _currentMode == CommandPaletteMode::ActionMode) | ||
{ | ||
_updateFilteredActions(); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -1178,7 +1184,8 @@ namespace winrt::TerminalApp::implementation | |
for (const auto& nameAndCommand : parentCommand.NestedCommands()) | ||
{ | ||
const auto action = nameAndCommand.Value(); | ||
auto nestedActionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action) }; | ||
// nested commands cannot have keybinds bound to them, so just pass in the command and no keys | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
keybinds is not a recognized word. (unrecognized-spelling)
|
||
auto nestedActionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action, L"") }; | ||
auto nestedFilteredCommand{ winrt::make<FilteredCommand>(nestedActionPaletteItem) }; | ||
_currentNestedCommands.Append(nestedFilteredCommand); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,9 +113,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
if (cmdID == userID) | ||
{ | ||
_KeyMap.insert_or_assign(key, inboxCmd->second.ID()); | ||
|
||
// register the keys with the inbox action | ||
inboxCmd->second.RegisterKey(key); | ||
} | ||
} | ||
|
||
|
@@ -559,16 +556,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
return; | ||
} | ||
|
||
// Handle collisions | ||
if (const auto foundCommand = _GetActionByKeyChordInternal(keys); foundCommand && *foundCommand) | ||
{ | ||
// collision: the key chord is bound to some command, make sure that command erases | ||
// this key chord as we are about to overwrite it | ||
|
||
const auto foundCommandImpl{ get_self<implementation::Command>(*foundCommand) }; | ||
foundCommandImpl->EraseKey(keys); | ||
} | ||
|
||
// Assign the new action in the _KeyMap | ||
// However, there's a strange edge case here - since we're parsing a legacy or modern block, | ||
// the user might have { "command": null, "id": "someID", "keys": "ctrl+c" } | ||
|
@@ -686,12 +673,23 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
// Return Value: | ||
// - the key chord that executes the given action | ||
// - nullptr if the action is not bound to a key chord | ||
Control::KeyChord ActionMap::GetKeyBindingForAction(winrt::hstring cmdID) const | ||
Control::KeyChord ActionMap::GetKeyBindingForAction(winrt::hstring cmdID) | ||
{ | ||
// Check our internal state. | ||
if (const auto cmd{ _GetActionByID(cmdID) }) | ||
if (!_ResolvedKeyActionMapCache) | ||
{ | ||
return cmd.Keys(); | ||
_RefreshKeyBindingCaches(); | ||
} | ||
|
||
// I dislike that we have to do an O(n) lookup everytime we want to get the keybinding for an action - | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
everytime is not a recognized word. (unrecognized-spelling)
|
||
// an alternative is having the key->action map be a bimap (would require a dependency), or store another map that is just | ||
Check failure Code scanning / check-spelling Unrecognized Spelling Error
bimap is not a recognized word. (unrecognized-spelling)
|
||
// the reverse direction (action->key) which would be mean storing the same data twice but getting faster lookup | ||
for (const auto [key, action] : _ResolvedKeyActionMapCache) | ||
{ | ||
if (action.ID() == cmdID) | ||
{ | ||
// if there are multiple keys bound to this action, we will just return the first one we find | ||
return key; | ||
} | ||
} | ||
|
||
// This key binding does not exist | ||
|
@@ -727,11 +725,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
_KeyMap.insert_or_assign(oldKeys, L""); | ||
} | ||
|
||
// make sure to update the Command with these changes | ||
const auto cmdImpl{ get_self<implementation::Command>(cmd) }; | ||
cmdImpl->EraseKey(oldKeys); | ||
cmdImpl->RegisterKey(newKeys); | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -769,7 +762,6 @@ namespace winrt::Microsoft::Terminal::Settings::Model::implementation | |
void ActionMap::RegisterKeyBinding(Control::KeyChord keys, Model::ActionAndArgs action) | ||
{ | ||
auto cmd{ make_self<Command>() }; | ||
cmd->RegisterKey(keys); | ||
cmd->ActionAndArgs(action); | ||
cmd->GenerateID(); | ||
AddAction(*cmd, keys); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
ba375ec
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.
@check-spelling-bot Report
🔴 Please review
See the 📜action log or 📝 job summary for details.
Unrecognized words (4)
bimap
everytime
keybinds
Unregistering
Previously acknowledged words that are now absent
CRLFs Redir unregistering wcsicmp 🫥To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the git@github.com:microsoft/terminal.git repository
on the
dev/pabhoj/command_keys
branch (ℹ️ how do I use this?):Available 📚 dictionaries could cover words (expected and unrecognized) not in the 📘 dictionary
This includes both expected items (2207) from .github/actions/spelling/expect/04cdb9b77d6827c0202f51acd4205b017015bfff.txt
.github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt and unrecognized words (4)
Consider adding them (in
.github/workflows/spelling2.yml
) foruses: check-spelling/check-spelling@v0.0.22
in itswith
:To stop checking additional dictionaries, add (in
.github/workflows/spelling2.yml
) foruses: check-spelling/check-spelling@v0.0.22
in itswith
:Errors (1)
See the 📜action log or 📝 job summary for details.
See ❌ Event descriptions for more information.
✏️ Contributor please read this
By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.
If the listed items are:
.github/actions/spelling/allow/names.txt
..github/actions/spelling/allow/
..github/actions/spelling/expect/
..github/actions/spelling/patterns/
.See the
README.md
in each directory for more information.🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉
If the flagged items are 🤯 false positives
If items relate to a ...
binary file (or some other file you wouldn't want to check at all).
Please add a file path to the
excludes.txt
file matching the containing file.File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^
refers to the file's path from the root of the repository, so^README\.md$
would exclude README.md (on whichever branch you're using).well-formed pattern.
If you can write a pattern that would match it,
try adding it to the
patterns.txt
file.Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.