Skip to content

Commit 3c59b4e

Browse files
SteveL-MSFTkilasuit
authored andcommitted
Update upgrade notification message (PowerShell#10777)
1 parent d985c47 commit 3c59b4e

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

src/Microsoft.PowerShell.ConsoleHost/host/msh/UpdatesNotification.cs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,33 @@ internal static void ShowUpdateNotification(PSHostUserInterface hostUI)
6262
? ManagedEntranceStrings.StableUpdateNotificationMessage
6363
: ManagedEntranceStrings.PreviewUpdateNotificationMessage;
6464

65-
string notificationMsg = string.Format(CultureInfo.CurrentCulture, notificationMsgTemplate, releaseTag);
65+
string notificationColor = string.Empty;
66+
string resetColor = string.Empty;
67+
68+
string line2Padding = string.Empty;
69+
string line3Padding = string.Empty;
70+
71+
// We calculate how much whitespace we need to make it look nice
72+
if (hostUI.SupportsVirtualTerminal)
73+
{
74+
// Use Warning Color
75+
notificationColor = "\x1B[7m";
76+
resetColor = "\x1B[0m";
77+
78+
// The first line is longest, if the message changes, this needs to be updated
79+
int line1Length = notificationMsgTemplate.IndexOf('\n');
80+
int line2Length = notificationMsgTemplate.IndexOf('\n', line1Length + 1);
81+
int line3Length = notificationMsgTemplate.IndexOf('\n', line2Length + 1);
82+
line3Length -= line2Length + 1;
83+
line2Length -= line1Length + 1;
84+
85+
line2Padding = line2Padding.PadRight(line1Length - line2Length + releaseTag.Length);
86+
// 3 represents the extra placeholder in the template
87+
line3Padding = line3Padding.PadRight(line1Length - line3Length + 3);
88+
}
89+
90+
string notificationMsg = string.Format(CultureInfo.CurrentCulture, notificationMsgTemplate, releaseTag, notificationColor, resetColor, line2Padding, line3Padding);
91+
6692
hostUI.WriteLine(notificationMsg);
6793
}
6894
}

src/Microsoft.PowerShell.ConsoleHost/resources/ManagedEntranceStrings.resx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ Type 'help' to get help.</value>
128128
<value>Warning: PowerShell detected that you might be using a screen reader and has disabled PSReadLine for compatibility purposes. If you want to re-enable it, run 'Import-Module PSReadLine'.</value>
129129
</data>
130130
<data name="PreviewUpdateNotificationMessage" xml:space="preserve">
131-
<value>!! A new PowerShell preview release is available: v{0} !!
132-
Upgrade now, or check out the release page at:
133-
https://github.com/PowerShell/PowerShell/releases/tag/v{0}
131+
<value> {1} A new PowerShell preview release is available: v{0} {2}
132+
{1} Upgrade now, or check out the release page at:{3}{2}
133+
{1} https://aka.ms/PowerShell-Release?tag=v{0} {4}{2}
134134
</value>
135135
</data>
136136
<data name="StableUpdateNotificationMessage" xml:space="preserve">
137-
<value>!! A new PowerShell stable release is available: v{0} !!
138-
Upgrade now, or check out the release page at:
139-
https://github.com/PowerShell/PowerShell/releases/tag/v{0}
137+
<value> {1} A new PowerShell stable release is available: v{0} {2}
138+
{1} Upgrade now, or check out the release page at:{3}{2}
139+
{1} https://aka.ms/PowerShell-Release?tag=v{0} {4}{2}
140140
</value>
141141
</data>
142142
<data name="UsageHelp" xml:space="preserve">

0 commit comments

Comments
 (0)