Correct Copy Keybinding Arg Default Behavior (#3823)

This commit is contained in:
Carlos Zamora 2019-12-03 19:27:56 -05:00 committed by Dustin L. Howett (MSFT)
parent 5585183d7d
commit 04432ee5de
4 changed files with 10 additions and 10 deletions

View file

@ -108,8 +108,8 @@
"action": { "type": "string", "pattern": "copy" }, "action": { "type": "string", "pattern": "copy" },
"trimWhitespace": { "trimWhitespace": {
"type": "boolean", "type": "boolean",
"default": false, "default": true,
"description": "If true, will trim whitespace from the end of the line on copy." "description": "If true, whitespace is removed and newlines are maintained. If false, newlines are removed and whitespace is maintained."
} }
} }
} }

View file

@ -229,24 +229,24 @@ namespace TerminalAppLocalTests
{ {
Log::Comment(NoThrowString().Format( 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') }; KeyChord kc{ true, false, false, static_cast<int32_t>('C') };
auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc);
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>(); const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs); VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value // Verify the args have the expected value
VERIFY_IS_FALSE(realArgs.TrimWhitespace()); VERIFY_IS_TRUE(realArgs.TrimWhitespace());
} }
{ {
Log::Comment(NoThrowString().Format( 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') }; KeyChord kc{ false, true, false, static_cast<int32_t>('C') };
auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc);
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>(); const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs); VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value // Verify the args have the expected value
VERIFY_IS_TRUE(realArgs.TrimWhitespace()); VERIFY_IS_FALSE(realArgs.TrimWhitespace());
} }
{ {
@ -341,7 +341,7 @@ namespace TerminalAppLocalTests
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>(); const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs); VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value // Verify the args have the expected value
VERIFY_IS_FALSE(realArgs.TrimWhitespace()); VERIFY_IS_TRUE(realArgs.TrimWhitespace());
} }
{ {
@ -353,7 +353,7 @@ namespace TerminalAppLocalTests
const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>(); const auto& realArgs = actionAndArgs.Args().try_as<CopyTextArgs>();
VERIFY_IS_NOT_NULL(realArgs); VERIFY_IS_NOT_NULL(realArgs);
// Verify the args have the expected value // Verify the args have the expected value
VERIFY_IS_FALSE(realArgs.TrimWhitespace()); VERIFY_IS_TRUE(realArgs.TrimWhitespace());
} }
{ {

View file

@ -37,7 +37,7 @@ namespace winrt::TerminalApp::implementation
struct CopyTextArgs : public CopyTextArgsT<CopyTextArgs> struct CopyTextArgs : public CopyTextArgsT<CopyTextArgs>
{ {
CopyTextArgs() = default; CopyTextArgs() = default;
GETSET_PROPERTY(bool, TrimWhitespace, false); GETSET_PROPERTY(bool, TrimWhitespace, true);
static constexpr std::string_view TrimWhitespaceKey{ "trimWhitespace" }; static constexpr std::string_view TrimWhitespaceKey{ "trimWhitespace" };

View file

@ -260,7 +260,7 @@ std::function<IActionArgs(const Json::Value&)> LegacyParseSwitchToTabArgs(int in
IActionArgs LegacyParseCopyTextWithoutNewlinesArgs(const Json::Value& /*json*/) IActionArgs LegacyParseCopyTextWithoutNewlinesArgs(const Json::Value& /*json*/)
{ {
auto args = winrt::make_self<winrt::TerminalApp::implementation::CopyTextArgs>(); auto args = winrt::make_self<winrt::TerminalApp::implementation::CopyTextArgs>();
args->TrimWhitespace(true); args->TrimWhitespace(false);
return *args; return *args;
}; };