From ed0c073eae5358b509c68e3051c489bd25be30c9 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Wed, 20 May 2020 06:24:09 +0300 Subject: Several fixes and improvements after first real test against PPC. --- .../Visual_Studio/Tango.Console/ConsoleTextBox.cs | 37 ++++++++++++++-------- 1 file changed, 23 insertions(+), 14 deletions(-) (limited to 'Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs') diff --git a/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs index d2d20b629..f6fa40b13 100644 --- a/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs +++ b/Software/Visual_Studio/Tango.Console/ConsoleTextBox.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -197,29 +198,37 @@ namespace Tango.Console { base.OnTextChanged(e); - if (CaretIndex == Text.Length) + try { - String lastWord = Text.Split(' ').LastOrDefault(); - lastWord?.Trim(); - - if (Suggestions != null) + if (CaretIndex == Text.Length) { - FilteredSuggestions = Suggestions.Where(x => (lastWord.IsNotNullOrEmpty() && x.Name.ToLower().StartsWith(lastWord.ToLower())) || Text.EndsWith(" ")).OrderBy(x => x.Name).Take(MaxSuggestions).ToList(); + String lastWord = Text.Split(' ').LastOrDefault(); + lastWord?.Trim(); - if (Text.Contains(" ")) + if (Suggestions != null) { - FilteredSuggestions = FilteredSuggestions.Where(x => x.Type != ConsoleSuggestionType.Command).ToList(); - } + FilteredSuggestions = Suggestions.Where(x => (lastWord.IsNotNullOrEmpty() && x.Name.ToLower().StartsWith(lastWord.ToLower())) || Text.EndsWith(" ")).OrderBy(x => x.Name).Take(MaxSuggestions).ToList(); + + if (Text.Contains(" ")) + { + FilteredSuggestions = FilteredSuggestions.Where(x => x.Type != ConsoleSuggestionType.Command).ToList(); + } - IsSuggestionsOpened = FilteredSuggestions.Count > 0; + IsSuggestionsOpened = FilteredSuggestions.Count > 0; + _popup.IsOpen = false; + _popup.IsOpen = FilteredSuggestions.Count > 0 && SelectedSuggestion != null; + } + } + else + { + IsSuggestionsOpened = false; _popup.IsOpen = false; - _popup.IsOpen = FilteredSuggestions.Count > 0 && SelectedSuggestion != null; } } - else + catch (Exception ex) { - IsSuggestionsOpened = false; - _popup.IsOpen = false; + Debug.WriteLine(ex); + Debugger.Break(); } } -- cgit v1.3.1