Skip to content

Commit 8f26dea

Browse files
committed
Address comment
1 parent 9862f86 commit 8f26dea

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,12 @@ class ConsoleHostRawUserInterface : System.Management.Automation.Host.PSHostRawU
4545
var principal = new WindowsPrincipal(identity);
4646
if (principal.IsInRole(WindowsBuiltInRole.Administrator))
4747
{
48-
// check using Regex if the window already has Administrator: prefix
49-
// (i.e. from the parent console process)
50-
string template = ConsoleHostRawUserInterfaceStrings.WindowTitleTemplate;
51-
string windowTitle = WindowTitle;
52-
if (!windowTitle.AsSpan().StartsWith(template.AsSpan(0, template.IndexOf('{'))))
48+
// Check if the window already has the "Administrator: " prefix (i.e. from the parent console process).
49+
ReadOnlySpan<char> prefix = ConsoleHostRawUserInterfaceStrings.WindowTitleElevatedPrefix;
50+
ReadOnlySpan<char> windowTitle = WindowTitle;
51+
if (!windowTitle.StartsWith(prefix))
5352
{
54-
WindowTitle = StringUtil.Format(template, windowTitle);
53+
WindowTitle = string.Concat(prefix, windowTitle);
5554
}
5655
}
5756
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
<data name="WindowTitleTooLongErrorTemplate" xml:space="preserve">
172172
<value>Window title cannot be longer than {0} characters.</value>
173173
</data>
174-
<data name="WindowTitleTemplate" xml:space="preserve">
175-
<value>Administrator: {0}</value>
174+
<data name="WindowTitleElevatedPrefix" xml:space="preserve">
175+
<value>Administrator: </value>
176176
</data>
177177
</root>

0 commit comments

Comments
 (0)