From aa3de1b749800a6f82f4b04d559af33e0f450610 Mon Sep 17 00:00:00 2001 From: RogueAI42 Date: Tue, 1 Aug 2017 17:47:09 +1000 Subject: [PATCH] stab in the dark to fix this startup exception It doesn't actually happen for me. I rewrote GetCurrentLine() to be more consistent with the rest of the codebase about newlines, hopefully this will work for everyone. --- ShiftOS.Frontend/Apps/Terminal.cs | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ShiftOS.Frontend/Apps/Terminal.cs b/ShiftOS.Frontend/Apps/Terminal.cs index 5cf899f..0f8ddde 100644 --- a/ShiftOS.Frontend/Apps/Terminal.cs +++ b/ShiftOS.Frontend/Apps/Terminal.cs @@ -76,13 +76,14 @@ namespace ShiftOS.Frontend.Apps Dock = GUI.DockStyle.Fill; } + + private static readonly string[] delimiters = { Environment.NewLine }; public string[] Lines { get { - return Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None); - + return Text.Split(delimiters, StringSplitOptions.None); } } @@ -121,18 +122,11 @@ namespace ShiftOS.Frontend.Apps } + private static readonly Regex regexNl = new Regex(Regex.Escape(Environment.NewLine)); + public int GetCurrentLine() { - int line = 0; - for(int i = 0; i < Index; i++) - { - if(Text[i]=='\n') - { - line++; - continue; - } - } - return line; + return regexNl.Matches(Text.Substring(0, Index)).Count; } float _vertOffset = 0.0f;