Browse Source

Deal with null cki

Tig Kindel 2 years ago
parent
commit
86a0f0510f

+ 8 - 1
Terminal.Gui/ConsoleDrivers/NetDriver.cs

@@ -197,7 +197,14 @@ namespace Terminal.Gui {
 						break;
 					}
 				} else if (consoleKeyInfo.KeyChar == (char)Key.Esc && isEscSeq) {
-					DecodeEscSeq (ref newConsoleKeyInfo, ref key, cki, ref mod);
+					if (cki == null) {
+						// This is an error. We got an ESC while we're in an ESC sequence already
+						// but there's no record of the ESC sequence.
+						// Ignore this for now until we can figure out how we got in this state
+						isEscSeq = false;
+					} else {
+						DecodeEscSeq (ref newConsoleKeyInfo, ref key, cki, ref mod);
+					}
 					cki = null;
 					break;
 				} else {

+ 3 - 0
Terminal.Gui/Core/EscSeqUtils/EscSeqUtils.cs

@@ -421,6 +421,9 @@ namespace Terminal.Gui {
 		/// <returns>The char array of the escape sequence.</returns>
 		public static char [] GetKeyCharArray (ConsoleKeyInfo [] cki)
 		{
+			if (cki == null) {
+				return null;
+			}
 			char [] kChar = new char [] { };
 			var length = 0;
 			foreach (var kc in cki) {