File tree Expand file tree Collapse file tree
src/System.Management.Automation/engine/CommandCompletion Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,7 +62,19 @@ internal static IEnumerable<CompletionResult> GetMatchingResults(
6262 /// <param name="wordToComplete">The word to complete.</param>
6363 /// <returns>The normalized word with escaped newlines replaced.</returns>
6464 internal static string NormalizeLineEndings ( string wordToComplete )
65- => wordToComplete . Replace ( "\r " , "`r" ) . Replace ( "\n " , "`n" ) ;
65+ {
66+ if ( wordToComplete . Contains ( '\r ' ) )
67+ {
68+ wordToComplete = wordToComplete . Replace ( "\r " , "`r" ) ;
69+ }
70+
71+ if ( wordToComplete . Contains ( '\n ' ) )
72+ {
73+ wordToComplete = wordToComplete . Replace ( "\n " , "`n" ) ;
74+ }
75+
76+ return wordToComplete ;
77+ }
6678
6779 /// <summary>
6880 /// Defines a strategy for determining if a value matches a word or pattern.
You can’t perform that action at this time.
0 commit comments