From a0f845f4175e8655fda0a138b2c857c469ad2c3b Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 25 May 2017 12:00:48 -0700 Subject: [PATCH 1/2] Fix PSReadline to render correct portion of prompt when it's a multi-line string --- src/Microsoft.PowerShell.PSReadLine/ReadLine.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs b/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs index d221d698dfe..f1fd529eda0 100644 --- a/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs +++ b/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs @@ -560,6 +560,13 @@ private void Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics) #if UNIX // TODO: not necessary if ReadBufferLines worked, or if rendering worked on spans instead of complete lines string newPrompt = GetPrompt(); + int index = newPrompt.LastIndexOf('\n'); + if (index != -1) + { + // The prompt text could be a multi-line string, and in such case + // we only want the part of it shown on the current line. + newPrompt = newPrompt.Substring(index + 1); + } var bufferLineCount = (newPrompt.Length) / (_console.BufferWidth) + 1; _consoleBuffer = ReadBufferLines(_initialY, bufferLineCount); From 5cf5e3b23ad9bba66261b464dc8934ad3c8d7c15 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Thu, 25 May 2017 16:44:44 -0700 Subject: [PATCH 2/2] Update comment --- src/Microsoft.PowerShell.PSReadLine/ReadLine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs b/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs index f1fd529eda0..0282d77841f 100644 --- a/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs +++ b/src/Microsoft.PowerShell.PSReadLine/ReadLine.cs @@ -564,7 +564,7 @@ private void Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics) if (index != -1) { // The prompt text could be a multi-line string, and in such case - // we only want the part of it shown on the current line. + // we only want the part of it that is shown on the input line. newPrompt = newPrompt.Substring(index + 1); } var bufferLineCount = (newPrompt.Length) / (_console.BufferWidth) + 1;