From 055703126d799407bee2b3bdfe26e0641748d066 Mon Sep 17 00:00:00 2001 From: "Dan Thompson (SBS)" Date: Wed, 3 Mar 2021 22:24:35 -0800 Subject: [PATCH] Update ControlSequenceLength to handle colon VT param separators The ControlSequenceLength function calculates the length of a VT control sequence--used by LengthInBufferCells. SGR control sequences might have parameters, separated by semicolons... or possibly colons. See: https://github.com/microsoft/terminal/issues/4321 This change updates ControlSequenceLength to treat colons similarly to semicolons. --- .../host/msh/ConsoleControl.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs index a157964c637..7670731fc16 100644 --- a/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs +++ b/src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleControl.cs @@ -2654,7 +2654,7 @@ internal static void SetConsoleTextAttribute(ConsoleHandle consoleHandle, WORD a // CSI params? '#' [{}pq] // XTPUSHSGR ('{'), XTPOPSGR ('}'), or their aliases ('p' and 'q') // // Where: - // params: digit+ (';' params)? + // params: digit+ ((';' | ':') params)? // CSI: C0_CSI | C1_CSI // C0_CSI: \x001b '[' // ESC '[' // C1_CSI: \x009b @@ -2699,7 +2699,7 @@ internal static int ControlSequenceLength(string str, ref int offset) { c = str[offset++]; } - while ((offset < str.Length) && (char.IsDigit(c) || c == ';')); + while ((offset < str.Length) && (char.IsDigit(c) || (c == ';') || (c == ':'))); // Finally, handle the command characters for the specific sequences we // handle: