From 04432ee5def49595da96a81897544e27afef7c25 Mon Sep 17 00:00:00 2001 From: Carlos Zamora Date: Tue, 3 Dec 2019 19:27:56 -0500 Subject: [PATCH] Correct Copy Keybinding Arg Default Behavior (#3823) --- doc/cascadia/profiles.schema.json | 4 ++-- .../LocalTests_TerminalApp/KeyBindingsTests.cpp | 12 ++++++------ src/cascadia/TerminalApp/ActionArgs.h | 2 +- .../TerminalApp/AppKeyBindingsSerialization.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/cascadia/profiles.schema.json b/doc/cascadia/profiles.schema.json index 0a0da3873..4e75f04be 100644 --- a/doc/cascadia/profiles.schema.json +++ b/doc/cascadia/profiles.schema.json @@ -108,8 +108,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." } } } diff --git a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp index 91cbd1bd6..733cd2194 100644 --- a/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp +++ b/src/cascadia/LocalTests_TerminalApp/KeyBindingsTests.cpp @@ -229,24 +229,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('C') }; auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); const auto& realArgs = actionAndArgs.Args().try_as(); 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('C') }; auto actionAndArgs = GetActionAndArgs(*appKeyBindings, kc); const auto& realArgs = actionAndArgs.Args().try_as(); VERIFY_IS_NOT_NULL(realArgs); // 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(); VERIFY_IS_NOT_NULL(realArgs); // 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(); VERIFY_IS_NOT_NULL(realArgs); // Verify the args have the expected value - VERIFY_IS_FALSE(realArgs.TrimWhitespace()); + VERIFY_IS_TRUE(realArgs.TrimWhitespace()); } { diff --git a/src/cascadia/TerminalApp/ActionArgs.h b/src/cascadia/TerminalApp/ActionArgs.h index 4e95f8552..ff32d187a 100644 --- a/src/cascadia/TerminalApp/ActionArgs.h +++ b/src/cascadia/TerminalApp/ActionArgs.h @@ -37,7 +37,7 @@ namespace winrt::TerminalApp::implementation struct CopyTextArgs : public CopyTextArgsT { CopyTextArgs() = default; - GETSET_PROPERTY(bool, TrimWhitespace, false); + GETSET_PROPERTY(bool, TrimWhitespace, true); static constexpr std::string_view TrimWhitespaceKey{ "trimWhitespace" }; diff --git a/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp b/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp index 423a4a222..3f2efc5fa 100644 --- a/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp +++ b/src/cascadia/TerminalApp/AppKeyBindingsSerialization.cpp @@ -260,7 +260,7 @@ std::function LegacyParseSwitchToTabArgs(int in IActionArgs LegacyParseCopyTextWithoutNewlinesArgs(const Json::Value& /*json*/) { auto args = winrt::make_self(); - args->TrimWhitespace(true); + args->TrimWhitespace(false); return *args; };