diff --git a/src/System.Management.Automation/utils/StringUtil.cs b/src/System.Management.Automation/utils/StringUtil.cs index 6bdedd03a3b..8daf31866df 100644 --- a/src/System.Management.Automation/utils/StringUtil.cs +++ b/src/System.Management.Automation/utils/StringUtil.cs @@ -202,7 +202,7 @@ internal static string VtSubstring(this string str, int startOffset, int length, } // If the number of copied non-escape-sequence characters has reached the specified length, done copying. - if (offset == length) + if (copyStarted && offset == length) { break; }