From e266ca6f67ab081476a0990e36e67ab4f2554e2b Mon Sep 17 00:00:00 2001 From: Snowy Date: Thu, 12 Mar 2026 04:23:22 +0800 Subject: [PATCH] Fix BackwardKillLine length calculation for multiline input (#5102) --- PSReadLine/KillYank.cs | 2 +- test/KillYankTest.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/PSReadLine/KillYank.cs b/PSReadLine/KillYank.cs index 77fe33f..c282b14 100644 --- a/PSReadLine/KillYank.cs +++ b/PSReadLine/KillYank.cs @@ -135,7 +135,7 @@ namespace Microsoft.PowerShell public static void BackwardKillLine(ConsoleKeyInfo? key = null, object arg = null) { var start = GetBeginningOfLinePos(_singleton._current); - _singleton.Kill(start, _singleton._current, true); + _singleton.Kill(start, _singleton._current - start, true); } /// diff --git a/test/KillYankTest.cs b/test/KillYankTest.cs index 381e788..5c631d5 100644 --- a/test/KillYankTest.cs +++ b/test/KillYankTest.cs @@ -119,6 +119,8 @@ namespace Test PSConsoleReadLine.SetKeyHandler(new[] { "Shift+Tab" }, PSConsoleReadLine.BackwardKillLine, "", ""); Test("", Keys("dir", _.Shift_Tab)); + + Test("abc\n123", Keys("abc", _.Shift_Enter, "123", _.Shift_Tab, _.Ctrl_y)); } [SkippableFact]