Skip to content
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 support for iterable, nested commands #6856

Merged
82 commits merged into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
c56eb8f
Add a ton of text regarding Commandline Mode vs Action Mode
zadjii-msft Apr 30, 2020
fe640ff
move this spec out of `drafts/`
zadjii-msft Apr 30, 2020
614d1b2
last little todos for review
zadjii-msft Apr 30, 2020
ead76d7
Merge remote-tracking branch 'origin/master' into dev/migrie/s/5400-C…
zadjii-msft May 7, 2020
2e56436
Move this section to 'future considerations'
zadjii-msft May 7, 2020
0886e8f
Merge remote-tracking branch 'origin/master' into dev/migrie/s/5400-C…
zadjii-msft May 20, 2020
11130a4
Add some notes about the advanced tab switcher and how that might int…
zadjii-msft May 20, 2020
f53553f
Merge remote-tracking branch 'origin/master' into dev/migrie/s/5400-C…
zadjii-msft May 28, 2020
0672812
good bot
zadjii-msft May 28, 2020
43bd483
Blind port these files from the old branch
zadjii-msft May 28, 2020
75af4ca
Hook up all the parsing once again
zadjii-msft May 28, 2020
33a9e32
Get names from the resources if provided as an object, not a string
zadjii-msft May 28, 2020
3627d8a
This should have been in the previous commit
zadjii-msft May 28, 2020
0416a94
Hook up the parsing of `ActionAndArgs`s to the command palette
zadjii-msft May 28, 2020
6905065
Merge remote-tracking branch 'origin/master' into dev/migrie/f/2046-C…
zadjii-msft May 28, 2020
02f47f4
Make the action names map public, so the ToJson in AKBSerialization c…
zadjii-msft May 28, 2020
62b9a0d
Move the action into it's own sub-object
zadjii-msft May 28, 2020
207666e
Add a ton of default commands
zadjii-msft May 29, 2020
b88be45
Make sure to scroll the selected item into view
zadjii-msft May 29, 2020
00763fd
Add duplicate pane to the default commands
zadjii-msft May 29, 2020
bc546db
Add some stability
zadjii-msft May 29, 2020
e1be26b
Do this in WinRTUtils instead of hackily doing it manually
zadjii-msft May 29, 2020
a309191
Rename private methods, fix wraparound logic
zadjii-msft May 29, 2020
9905945
Return focus to the active control when closed
zadjii-msft May 29, 2020
cf6e1f2
Try to do this with a shadow, but it crashes inexplicably
zadjii-msft May 29, 2020
fa93fdc
Well, this is neat, and works, but requires 18362 and also casts a sh…
zadjii-msft May 29, 2020
1fbe8e4
Turns out, the shadow on the menuflyout isn't my fault, it's on every…
zadjii-msft May 29, 2020
6e6979a
Extract ActionAndArgs::FromJson into it's own class, so it can be re-…
zadjii-msft Jun 4, 2020
829beda
Merge remote-tracking branch 'origin/master' into dev/migrie/f/2046-C…
zadjii-msft Jun 4, 2020
487f33e
Merge commit '6e6979abe' into dev/migrie/f/2046-Command-Palette-v2
zadjii-msft Jun 4, 2020
58be8cd
Tons of commenting
zadjii-msft Jun 4, 2020
9d411d4
Make the commands a map, so we can override on "name"
zadjii-msft Jun 4, 2020
d71d8d7
Ready for review.
zadjii-msft Jun 4, 2020
b3d8f0e
Merge remote-tracking branch 'origin/master' into dev/migrie/f/2046-C…
zadjii-msft Jun 9, 2020
67c7969
I couldn't tell you how long this took
zadjii-msft Jun 9, 2020
82f968d
If a key is bound to that action, then display the keybinding in the …
zadjii-msft Jun 9, 2020
edc8b55
Add much better key chord text to the command palette
zadjii-msft Jun 10, 2020
dd684cb
implement a weighted ordering for command palette entries
zadjii-msft Jun 10, 2020
3674c61
Add support for expanding a command into many commands for every prof…
zadjii-msft Jun 10, 2020
0b126f0
lets clean this up so it's not so horrifying.
zadjii-msft Jun 10, 2020
4420aea
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Jul 7, 2020
4e134e3
get it building again
zadjii-msft Jul 7, 2020
946d710
This works to auto-generate names from iterable commands without give…
zadjii-msft Jul 7, 2020
a5eba5a
add some stubs for tests in the future
zadjii-msft Jul 7, 2020
ac74de4
escape profile names for json before re-parsing
zadjii-msft Jul 8, 2020
7321639
re-use FromJson when expanding, as to not just duplicate the entire m…
zadjii-msft Jul 8, 2020
d953d8b
start working on nested actions
zadjii-msft Jul 8, 2020
dc7a816
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Jul 8, 2020
0c8471d
holy shit this worked on the first try
zadjii-msft Jul 8, 2020
bdd7e3b
write a test that _should_ check if an iterable command can have nest…
zadjii-msft Jul 8, 2020
93d31c2
This was a failure
zadjii-msft Jul 8, 2020
5052e64
Revert "This was a failure"
zadjii-msft Jul 8, 2020
c6a8fe9
more tests, more!
zadjii-msft Jul 9, 2020
f5659d2
this fixes `TestNestedInIterableCommand`, but `TestMixedNestedAndIter…
zadjii-msft Jul 9, 2020
077cd6e
this mysteriously fixes the mixed test, which I was pretty onfident I…
zadjii-msft Jul 9, 2020
26a1a41
man these are some great tests
zadjii-msft Jul 9, 2020
33ee177
clean up this duplicated code
zadjii-msft Jul 9, 2020
be5aee3
make sure to actually update the xaml lists as well.
zadjii-msft Jul 9, 2020
92167a5
code cleanup
zadjii-msft Jul 9, 2020
7968b2a
more tests, code cleanup
zadjii-msft Jul 9, 2020
c5208e6
finish remaining todos, also, good bot
zadjii-msft Jul 9, 2020
7cb870c
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Aug 3, 2020
8fd3e0d
These changes to defaults.json are out-of-date, and Command doesn't n…
zadjii-msft Aug 3, 2020
2763c90
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Aug 4, 2020
3d0c81c
the tiniest nit
zadjii-msft Aug 4, 2020
50bdc3d
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Aug 5, 2020
2a8d4c5
well, we definitely want this
zadjii-msft Aug 5, 2020
0719b42
This makes command expansion the TerminalPage's responsibility, but i…
zadjii-msft Aug 5, 2020
77e51af
expand commands every time the list of tabs changes
zadjii-msft Aug 5, 2020
1e9bf47
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Aug 11, 2020
b60b82b
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Aug 11, 2020
ec2db21
I guess we only really need to do this once
zadjii-msft Aug 11, 2020
c8c0032
Merge remote-tracking branch 'origin/dev/migrie/f/6856-let-terminalpa…
zadjii-msft Aug 11, 2020
b4eb86d
nits from PR
zadjii-msft Aug 11, 2020
1975e8c
Merge remote-tracking branch 'origin/master' into dev/migrie/f/comman…
zadjii-msft Aug 12, 2020
57abe29
Add a helper for find/replace-ing a string
zadjii-msft Aug 12, 2020
9981126
Clean up our string handling substantially
zadjii-msft Aug 12, 2020
c55d53e
minor nits, more tracing
zadjii-msft Aug 12, 2020
3269309
some cleaner lifetime management for these variables
zadjii-msft Aug 12, 2020
933dc7e
use a IMap to store subcommands, and then generate the vector when we…
zadjii-msft Aug 13, 2020
5198142
Fix the localtests for commands
zadjii-msft Aug 13, 2020
7b014d9
Dustin wanted every command to not necessarily have a subcommand map,…
zadjii-msft Aug 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 37 additions & 36 deletions src/cascadia/LocalTests_TerminalApp/CommandTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using namespace Microsoft::Console;
using namespace TerminalApp;
using namespace winrt::TerminalApp;
using namespace winrt::Microsoft::Terminal::TerminalControl;
using namespace winrt::Windows::Foundation::Collections;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
using namespace WEX::Common;
Expand Down Expand Up @@ -61,25 +62,25 @@ namespace TerminalAppLocalTests
const auto commands1Json = VerifyParseSucceeded(commands1String);
const auto commands2Json = VerifyParseSucceeded(commands2String);

std::unordered_map<winrt::hstring, Command> commands;
VERIFY_ARE_EQUAL(0u, commands.size());
IMap<winrt::hstring, winrt::TerminalApp::Command> commands = winrt::single_threaded_map<winrt::hstring, winrt::TerminalApp::Command>();
VERIFY_ARE_EQUAL(0u, commands.Size());
{
auto warnings = implementation::Command::LayerJson(commands, commands0Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
}
VERIFY_ARE_EQUAL(1u, commands.size());
VERIFY_ARE_EQUAL(1u, commands.Size());

{
auto warnings = implementation::Command::LayerJson(commands, commands1Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
}
VERIFY_ARE_EQUAL(2u, commands.size());
VERIFY_ARE_EQUAL(2u, commands.Size());

{
auto warnings = implementation::Command::LayerJson(commands, commands2Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
}
VERIFY_ARE_EQUAL(4u, commands.size());
VERIFY_ARE_EQUAL(4u, commands.Size());
}

void CommandTests::LayerCommand()
Expand All @@ -95,13 +96,13 @@ namespace TerminalAppLocalTests
const auto commands2Json = VerifyParseSucceeded(commands2String);
const auto commands3Json = VerifyParseSucceeded(commands3String);

std::unordered_map<winrt::hstring, Command> commands;
VERIFY_ARE_EQUAL(0u, commands.size());
IMap<winrt::hstring, winrt::TerminalApp::Command> commands = winrt::single_threaded_map<winrt::hstring, winrt::TerminalApp::Command>();
VERIFY_ARE_EQUAL(0u, commands.Size());
{
auto warnings = implementation::Command::LayerJson(commands, commands0Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
VERIFY_ARE_EQUAL(1u, commands.size());
auto command = commands.at(L"action0");
VERIFY_ARE_EQUAL(1u, commands.Size());
auto command = commands.Lookup(L"action0");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::CopyText, command.Action().Action());
Expand All @@ -111,8 +112,8 @@ namespace TerminalAppLocalTests
{
auto warnings = implementation::Command::LayerJson(commands, commands1Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
VERIFY_ARE_EQUAL(1u, commands.size());
auto command = commands.at(L"action0");
VERIFY_ARE_EQUAL(1u, commands.Size());
auto command = commands.Lookup(L"action0");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::PasteText, command.Action().Action());
Expand All @@ -121,8 +122,8 @@ namespace TerminalAppLocalTests
{
auto warnings = implementation::Command::LayerJson(commands, commands2Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
VERIFY_ARE_EQUAL(1u, commands.size());
auto command = commands.at(L"action0");
VERIFY_ARE_EQUAL(1u, commands.Size());
auto command = commands.Lookup(L"action0");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::NewTab, command.Action().Action());
Expand All @@ -133,7 +134,7 @@ namespace TerminalAppLocalTests
// This last command should "unbind" the action.
auto warnings = implementation::Command::LayerJson(commands, commands3Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
VERIFY_ARE_EQUAL(0u, commands.size());
VERIFY_ARE_EQUAL(0u, commands.Size());
}
}

Expand All @@ -153,14 +154,14 @@ namespace TerminalAppLocalTests

const auto commands0Json = VerifyParseSucceeded(commands0String);

std::unordered_map<winrt::hstring, Command> commands;
VERIFY_ARE_EQUAL(0u, commands.size());
IMap<winrt::hstring, winrt::TerminalApp::Command> commands = winrt::single_threaded_map<winrt::hstring, winrt::TerminalApp::Command>();
VERIFY_ARE_EQUAL(0u, commands.Size());
auto warnings = implementation::Command::LayerJson(commands, commands0Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
VERIFY_ARE_EQUAL(5u, commands.size());
VERIFY_ARE_EQUAL(5u, commands.Size());

{
auto command = commands.at(L"command0");
auto command = commands.Lookup(L"command0");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -170,7 +171,7 @@ namespace TerminalAppLocalTests
VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle());
}
{
auto command = commands.at(L"command1");
auto command = commands.Lookup(L"command1");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -180,7 +181,7 @@ namespace TerminalAppLocalTests
VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Vertical, realArgs.SplitStyle());
}
{
auto command = commands.at(L"command2");
auto command = commands.Lookup(L"command2");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -190,7 +191,7 @@ namespace TerminalAppLocalTests
VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Horizontal, realArgs.SplitStyle());
}
{
auto command = commands.at(L"command4");
auto command = commands.Lookup(L"command4");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -200,7 +201,7 @@ namespace TerminalAppLocalTests
VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle());
}
{
auto command = commands.at(L"command5");
auto command = commands.Lookup(L"command5");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -217,17 +218,17 @@ namespace TerminalAppLocalTests
const std::string commands0String{ R"([ { "name": { "key": "DuplicateTabCommandKey"}, "command": "copy" } ])" };
const auto commands0Json = VerifyParseSucceeded(commands0String);

std::unordered_map<winrt::hstring, Command> commands;
VERIFY_ARE_EQUAL(0u, commands.size());
IMap<winrt::hstring, winrt::TerminalApp::Command> commands = winrt::single_threaded_map<winrt::hstring, winrt::TerminalApp::Command>();
VERIFY_ARE_EQUAL(0u, commands.Size());
{
auto warnings = implementation::Command::LayerJson(commands, commands0Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
VERIFY_ARE_EQUAL(1u, commands.size());
VERIFY_ARE_EQUAL(1u, commands.Size());

// NOTE: We're relying on DuplicateTabCommandKey being defined as
// "Duplicate Tab" here. If that string changes in our resources,
// this test will break.
auto command = commands.at(L"Duplicate tab");
auto command = commands.Lookup(L"Duplicate tab");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::CopyText, command.Action().Action());
Expand Down Expand Up @@ -257,18 +258,18 @@ namespace TerminalAppLocalTests

const auto commands0Json = VerifyParseSucceeded(commands0String);

std::unordered_map<winrt::hstring, Command> commands;
VERIFY_ARE_EQUAL(0u, commands.size());
IMap<winrt::hstring, winrt::TerminalApp::Command> commands = winrt::single_threaded_map<winrt::hstring, winrt::TerminalApp::Command>();
VERIFY_ARE_EQUAL(0u, commands.Size());
auto warnings = implementation::Command::LayerJson(commands, commands0Json);
VERIFY_ARE_EQUAL(0u, warnings.size());

// There are only 3 commands here: all of the `"none"`, `"auto"`,
// `"foo"`, `null`, and <no args> bindings all generate the same action,
// which will generate just a single name for all of them.
VERIFY_ARE_EQUAL(3u, commands.size());
VERIFY_ARE_EQUAL(3u, commands.Size());

{
auto command = commands.at(L"Split pane");
auto command = commands.Lookup(L"Split pane");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -278,7 +279,7 @@ namespace TerminalAppLocalTests
VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Automatic, realArgs.SplitStyle());
}
{
auto command = commands.at(L"Split pane, direction: vertical");
auto command = commands.Lookup(L"Split pane, split: vertical");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -288,7 +289,7 @@ namespace TerminalAppLocalTests
VERIFY_ARE_EQUAL(winrt::TerminalApp::SplitState::Vertical, realArgs.SplitStyle());
}
{
auto command = commands.at(L"Split pane, direction: horizontal");
auto command = commands.Lookup(L"Split pane, split: horizontal");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand All @@ -307,14 +308,14 @@ namespace TerminalAppLocalTests

const auto commands0Json = VerifyParseSucceeded(commands0String);

std::unordered_map<winrt::hstring, Command> commands;
VERIFY_ARE_EQUAL(0u, commands.size());
IMap<winrt::hstring, winrt::TerminalApp::Command> commands = winrt::single_threaded_map<winrt::hstring, winrt::TerminalApp::Command>();
VERIFY_ARE_EQUAL(0u, commands.Size());
auto warnings = implementation::Command::LayerJson(commands, commands0Json);
VERIFY_ARE_EQUAL(0u, warnings.size());
VERIFY_ARE_EQUAL(1u, commands.size());
VERIFY_ARE_EQUAL(1u, commands.Size());

{
auto command = commands.at(L"Split pane");
auto command = commands.Lookup(L"Split pane");
VERIFY_IS_NOT_NULL(command);
VERIFY_IS_NOT_NULL(command.Action());
VERIFY_ARE_EQUAL(ShortcutAction::SplitPane, command.Action().Action());
Expand Down
Loading