mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix prompt string to be platform agnostic and keep its trailing spaces (#7255)
This commit is contained in:
committed by
Dongbo Wang
parent
716ed2acbd
commit
f4a50eda0d
@@ -479,6 +479,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
prompt_str = code_str = string.Empty;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
string default_prompt_str = "PS > ";
|
||||
|
||||
int collectingPart = 1;
|
||||
foreach (char c in content)
|
||||
@@ -495,7 +496,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
if (collectingPart == 1)
|
||||
{
|
||||
prompt_str = "PS C:\\>";
|
||||
prompt_str = default_prompt_str;
|
||||
}
|
||||
code_str = builder.ToString().Trim();
|
||||
builder = new StringBuilder();
|
||||
@@ -507,7 +508,7 @@ namespace System.Management.Automation
|
||||
|
||||
if (collectingPart == 1)
|
||||
{
|
||||
prompt_str = "PS C:\\>";
|
||||
prompt_str = default_prompt_str;
|
||||
code_str = builder.ToString().Trim();
|
||||
remarks_str = string.Empty;
|
||||
}
|
||||
|
||||
@@ -606,13 +606,14 @@ namespace System.Management.Automation
|
||||
|
||||
int paraNodes = GetParaMamlNodeCount(xmlNode.ChildNodes);
|
||||
int count = 0;
|
||||
|
||||
// Don't trim the content if this is an "introduction" node.
|
||||
bool trim = ! string.Equals(xmlNode.Name, "maml:introduction", StringComparison.OrdinalIgnoreCase);
|
||||
foreach (XmlNode childNode in xmlNode.ChildNodes)
|
||||
{
|
||||
if (childNode.LocalName.Equals("para", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
++count;
|
||||
PSObject paraPSObject = GetParaPSObject(childNode, count != paraNodes);
|
||||
PSObject paraPSObject = GetParaPSObject(childNode, count != paraNodes, trim: trim);
|
||||
if (paraPSObject != null)
|
||||
mshObjects.Add(paraPSObject);
|
||||
continue;
|
||||
@@ -752,8 +753,9 @@ namespace System.Management.Automation
|
||||
/// </summary>
|
||||
/// <param name="xmlNode"></param>
|
||||
/// <param name="newLine"></param>
|
||||
/// <param name="trim"></param>
|
||||
/// <returns></returns>
|
||||
private static PSObject GetParaPSObject(XmlNode xmlNode, bool newLine)
|
||||
private static PSObject GetParaPSObject(XmlNode xmlNode, bool newLine, bool trim = true)
|
||||
{
|
||||
if (xmlNode == null)
|
||||
return null;
|
||||
@@ -771,7 +773,12 @@ namespace System.Management.Automation
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append(xmlNode.InnerText.Trim());
|
||||
var innerText = xmlNode.InnerText;
|
||||
if (trim)
|
||||
{
|
||||
innerText = innerText.Trim();
|
||||
}
|
||||
sb.Append(innerText);
|
||||
}
|
||||
|
||||
mshObject.Properties.Add(new PSNoteProperty("Text", sb.ToString()));
|
||||
|
||||
Reference in New Issue
Block a user