Repository: terminal
Issue: Scenario: The Command Palette
Labels: Area-UserInterface,Product-Terminal,Issue-Scenario,Area-CmdPal

##### [Original issue: #2046] [Original Spec: #2193] [v2 Spec: #5674] [Spec Addendum 1: #6532]

<details>
<summary>TODO for initial PR</summary>

* [x] The list view items should be clickable
* [x] The list should be sorted by weight, then _alphabetically_
* [x] There should be stronger weighting for consecutive chars. Case in point: the `sett` example below
* [x] If you click on a list view item, focus enters the list view item, and then you can't hit enter to select it.
* [x] tests tests tests tests.
* [x] The auto gen names should probably only have the first letter capitalized - I bet if I do that I'll have to revert it during the PR... hmm...

</details>


## v2.0 Follow-up work 

### Tasks
* [ ] Don't localize command names on the command palette #7039
* [ ] Add a setting to display Command Palette ActionMode entries in MRU order #6647
* [x] Add nested commands to the Command Palette #3994
* [x] Command palette entries should have optional icons #6644 
* [x] A nested cmdpal menu should show the parent command above the list of commands #7265
* [x] Add support for commands iterable on color schemes #7329
* [x] Command Palette: Add support for commandline mode #6677
* [x] Make keys in the command palette look like actual keys, like in VS Code #6645
* [x] Command palette search results should bold the matching text #6646
* [x] `commandPalette` keybinding should close the palette when it's open #6679
* [x] Add "recent commands' to Command Palette in commandline mode #8296
* [x] Make the Command Line Mode easier to access #8322 (make a argument to `toggleCommandPalette` to go straight to the commandline mode)

### Bugs
* [ ] ~`_compareCommandNames` should use locale-aware string comparisons #6953~ This is going to be done by #7039 actually.
* [ ] Command Palette search algorithm needs to prioritize "longest substring" match, may need multiple passes #6693
* [ ] #7911 [Screen Reader-Command Palette]-Narrator focus is not in sync while navigating using arrow keys in suggestion list after searching for any command.
* [x] #7907 [Screen Reader-Command Palette]:-Screen reader is not announcing the suggestions when user searches for the commands.
* [x] #13457 The "go back" button should pop only one layer of the stack, not go all the way back to the root (https://github.com/microsoft/terminal/pull/8051#issuecomment-722045813)
* [x] NewTab won't leave the Command Palette #7441
* [x] #7915 [Visual requirement-Command Palette]-Luminosity ratio is 4.046:1 which is less than 4.5:1 for the shortcut text appended to the Commands.
* [x] #7914 [Functional-Command Palette]- User is not able to perform action using shortcuts when command palette is open.
* [x] #7913 [Screen Reader-Command Palette]-Narrator focus moves separately onto the shortcut text which is appended to the command.
* [x] #7912 [Usable-Command Palette]-Keyboard shortcuts are not included in the sub menu of New Tab list item.
* [x] #7910 [Functional-Command Palette]- User is not able to move back from the New Tab sub menu as there is no functionality provided to move out of Sub menu.
* [x] #7908 [Screen Reader-Command Palette]-Screen reader user will not be able to identify the purpose of New Tab control if role and state are not appropriate.
* [x] Overlapping text in Command Palette submenu after deleting ">" #10140

## Related, but indirectly

* [x] Add an action that runs other actions (action chaining)? #5970
* [ ] New icons for UI elements #6867
* [x] Add a shortcut action for switching to a specific color scheme #5401
* [x] Enable sending input to the Terminal with a keybinding #3799
* [x] Megathread: Sometimes, focus moves weirdly #6680
  - [x] Launching "Find" from Command Palette doesn't focus the search box #6662

## Backlog work
* [ ] Consider refactoring CommandPalette + Switcher => LiveFilteringListView #7285
* [ ] Allow commands with user-defined names to be hidden from cmdpal #7179
* [ ] Add auto-suggestion to the Command-Palette wt arguments #7570
* [ ] Code Health: Consider checking we are not in the opening state, by hooking both `Opening` and `Open` events
* [ ] Code Health: The explicit implementation (in `CommandPalette::_lostFocusHandler`) can be generalized by checking if the focused element is a descendant of palette
* [ ] Additional commands could be previewable #9818
* [ ] Using --window in a wt action should do what you'd expect #10146
* [ ] Allow binding keys to a nested action, to open the palette directly to it's children #10209
* [x] #11026
* [ ] ~Keep the Command Palette around after executing a command #7011~
* [x] Nested previewable commands don't "cancel" when you navigate up the nesting stack #10165
* [x] Preview what actions will be run in commandline mode of the CmdPal #8344
* [x] Provide realtime commandline parsing feedback in the commandline mode of the command palette #7284
* [x] Allow commands to be previewed in the command palette #6689
* [x] #11049