Skip to content

Commit

Permalink
Correct Copy Keybinding Arg Default Behavior (#3823)
Browse files Browse the repository at this point in the history
(cherry picked from commit 04432ee)
  • Loading branch information
carlos-zamora authored and DHowett committed Dec 4, 2019
1 parent da5a628 commit c33a138
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
"action": { "type": "string", "pattern": "copy" },
"trimWhitespace": {
"type": "boolean",
"default": false,
"description": "If true, will trim whitespace from the end of the line on copy."
"default": true,
"description": "If true, whitespace is removed and newlines are maintained. If false, newlines are removed and whitespace is maintained."
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,24 @@ namespace TerminalAppLocalTests

{
Log::Comment(NoThrowString().Format(
L"Verify that `copy` without args parses as Copy(TrimWhitespace=false)"));
L"Verify that `copy` without args parses as Copy(TrimWhitespace=true)"));
KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc);
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value
VERIFY_IS_FALSE(realArgs.TrimWhitespace());
VERIFY_IS_TRUE(realArgs.TrimWhitespace());
}

{
Log::Comment(NoThrowString().Format(
L"Verify that `copyTextWithoutNewlines` parses as Copy(TrimWhitespace=true)"));
L"Verify that `copyTextWithoutNewlines` parses as Copy(TrimWhitespace=false)"));
KeyChord kc{ false, true, false, static_cast<int32_t>('C') };
auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc);
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value
VERIFY_IS_TRUE(realArgs.TrimWhitespace());
VERIFY_IS_FALSE(realArgs.TrimWhitespace());
}

{
Expand Down Expand Up @@ -325,7 +325,7 @@ namespace TerminalAppLocalTests
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value
VERIFY_IS_FALSE(realArgs.TrimWhitespace());
VERIFY_IS_TRUE(realArgs.TrimWhitespace());
}

{
Expand All @@ -337,7 +337,7 @@ namespace TerminalAppLocalTests
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value
VERIFY_IS_FALSE(realArgs.TrimWhitespace());
VERIFY_IS_TRUE(realArgs.TrimWhitespace());
}

{
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/ActionArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace winrt::TerminalApp::implementation
struct CopyTextArgs : public CopyTextArgsT<CopyTextArgs>
{
CopyTextArgs() = default;
GETSET_PROPERTY(bool, TrimWhitespace, false);
GETSET_PROPERTY(bool, TrimWhitespace, true);

static constexpr std::string_view TrimWhitespaceKey{ "trimWhitespace" };

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ std::function<IActionArgs(const Json::Value&)> LegacyParseSwitchToTabArgs(int in
IActionArgs LegacyParseCopyTextWithoutNewlinesArgs(const Json::Value& /*json*/)
{
auto args = winrt::make_self<winrt::TerminalApp::implementation::CopyTextArgs>();
args->TrimWhitespace(true);
args->TrimWhitespace(false);
return *args;
};

Expand Down

0 comments on commit c33a138

Please sign in to comment.