Fix crash when terminal is reset (#6777)

* fix crash when terminal is reset

* fix check before removing characters
This commit is contained in:
Steve Lee
2018-05-08 12:53:13 -07:00
committed by Aditya Patwardhan
parent 1de9fb5589
commit 793160228a
@@ -1790,11 +1790,18 @@ namespace Microsoft.PowerShell
continue;
}
// Handle case where terminal gets reset and the index is outside of the buffer
if (index > s.Length)
{
index = s.Length;
}
// Modify string
if (!insertMode) // then overwrite mode
if (!insertMode && index < s.Length) // then overwrite mode
{
s = s.Remove(index, 1);
}
s = s.Insert(index, keyInfo.KeyChar.ToString());
index++;