Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal ConsoleHostUserInterface(ConsoleHost parent)
if (Environment.GetEnvironmentVariable("NO_COLOR") != null)
{
PSStyle.Instance.OutputRendering = OutputRendering.PlainText;
}
}
}

if (SupportsVirtualTerminal)
Expand Down Expand Up @@ -961,7 +961,7 @@ internal List<string> WrapText(string text, int maxWidthInBufferCells)
int w = maxWidthInBufferCells - cellCounter;
Dbg.Assert(w < e.Current.CellCount, "width remaining should be less than size of word");

line.Append(e.Current.Text.Substring(0, w));
line.Append(e.Current.Text.AsSpan(0, w));

l = line.ToString();
Dbg.Assert(RawUI.LengthInBufferCells(l) == maxWidthInBufferCells, "line should exactly fit");
Expand Down Expand Up @@ -2019,8 +2019,7 @@ internal string ReadLineWithTabCompletion(Executor exec)
var completionResult = commandCompletion.GetNextResult(rlResult == ReadLineResult.endedOnTab);
if (completionResult != null)
{
completedInput = completionInput.Substring(0, commandCompletion.ReplacementIndex)
+ completionResult.CompletionText;
completedInput = string.Concat(completionInput.AsSpan(0, commandCompletion.ReplacementIndex), completionResult.CompletionText);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ internal static bool IsMinimalProgressRenderingEnabled()
int maxStatusLength = barWidth - secRemainLength - 1;
if (maxStatusLength > 0 && StatusDescription.Length > barWidth - secRemainLength)
{
sb.Append(StatusDescription.Substring(0, barWidth - secRemainLength - 1));
sb.Append(StatusDescription.AsSpan(0, barWidth - secRemainLength - 1));
sb.Append(PSObjectHelper.Ellipsis);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ internal static List<CompletionResult> CompleteCommandArgument(CompletionContext

if (ret != null && ret.Count > 0)
{
var prefix = TokenKind.LParen.Text() + input.Substring(0, fakeReplacementIndex);
string prefix = string.Concat(TokenKind.LParen.Text(), input.AsSpan(0, fakeReplacementIndex));
foreach (CompletionResult entry in ret)
{
string completionText = prefix + entry.CompletionText;
Expand Down Expand Up @@ -5394,11 +5394,11 @@ private static FunctionDefinitionAst GetCommentHelpFunctionTarget(CompletionCont

return null;
}

private static List<CompletionResult> CompleteCommentParameterValue(CompletionContext context, string wordToComplete)
{
FunctionDefinitionAst foundFunction = GetCommentHelpFunctionTarget(context);

ReadOnlyCollection<ParameterAst> foundParameters = null;
if (foundFunction is not null)
{
Expand All @@ -5409,7 +5409,7 @@ private static List<CompletionResult> CompleteCommentParameterValue(CompletionCo
// The helpblock is for a script file
foundParameters = scriptAst.ParamBlock?.Parameters;
}

if (foundParameters is null || foundParameters.Count == 0)
{
return null;
Expand Down Expand Up @@ -6531,7 +6531,7 @@ internal static List<CompletionResult> CompleteHelpTopics(CompletionContext cont

//search for help files for the current culture + en-US as fallback
var searchPaths = new string[]
{
{
Path.Combine(userHelpDir, currentCulture),
Path.Combine(appHelpDir, currentCulture),
Path.Combine(userHelpDir, "en-US"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ internal static string ResolvePath(string path, ExecutionContext context)
{
ProviderInfo fileSystemProvider = context.EngineSessionState.GetSingleProvider(FileSystemProvider.ProviderName);
return new StringBuilder(fileSystemProvider.Home)
.Append(path.Substring(1))
.Append(path.AsSpan(1))
.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)
.ToString();
}
Expand Down
3 changes: 2 additions & 1 deletion src/System.Management.Automation/engine/debugger/debugger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1807,7 +1807,8 @@ private void OnDebuggerStop(InvocationInfo invocationInfo, List<Breakpoint> brea
{
// Fix up prompt.
++index;
string debugPrompt = "\"[DBG]: " + originalPromptString.Substring(index, originalPromptString.Length - index);
string debugPrompt = string.Concat("\"[DBG]: ", originalPromptString.AsSpan(index, originalPromptString.Length - index));

defaultPromptInfo.Update(
ScriptBlock.Create(debugPrompt), true, ScopedItemOptions.Unspecified);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ internal static void BuildHotkeysAndPlainLabels(Collection<ChoiceDescription> ch
Text.StringBuilder splitLabel = new Text.StringBuilder(choices[i].Label.Substring(0, andPos), choices[i].Label.Length);
if (andPos + 1 < choices[i].Label.Length)
{
splitLabel.Append(choices[i].Label.Substring(andPos + 1));
splitLabel.Append(choices[i].Label.AsSpan(andPos + 1));
hotkeysAndPlainLabels[0, i] = CultureInfo.CurrentCulture.TextInfo.ToUpper(choices[i].Label.AsSpan(andPos + 1, 1).Trim().ToString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ private static string GetSection(List<string> commentLines, ref int i)
start++;
}

sb.Append(line.Substring(start));
sb.Append(line.AsSpan(start));
sb.Append('\n');
}

Expand Down