Add namespace autocompletions, some adjustments to autocomplete logic

This commit is contained in:
Sinai
2021-05-17 23:20:06 +10:00
parent d7b0fff949
commit 019e589947
4 changed files with 102 additions and 91 deletions

View File

@ -77,17 +77,30 @@ namespace UnityExplorer.UI.CSConsole
select new Suggestion(GetHighlightString(prefix, completion), completion));
}
// Get manual namespace completions
foreach (var ns in ReflectionUtility.AllNamespaces)
{
if (ns.StartsWith(input))
{
if (!namespaceHighlights.ContainsKey(ns))
namespaceHighlights.Add(ns, $"<color=#CCCCCC>{ns}</color>");
string completion = ns.Substring(input.Length, ns.Length - input.Length);
suggestions.Add(new Suggestion(namespaceHighlights[ns], completion));
}
}
// Get manual keyword completions
foreach (var kw in KeywordLexer.keywords)
{
if (kw.StartsWith(input) && kw.Length > input.Length)
if (kw.StartsWith(input))// && kw.Length > input.Length)
{
if (!keywordHighlights.ContainsKey(kw))
keywordHighlights.Add(kw, $"<color=#{SignatureHighlighter.keywordBlueHex}>{kw}</color>");
string completion = kw.Substring(input.Length, kw.Length - input.Length);
suggestions.Add(new Suggestion(keywordHighlights[kw], completion));
}
}
@ -103,6 +116,9 @@ namespace UnityExplorer.UI.CSConsole
}
}
private readonly Dictionary<string, string> namespaceHighlights = new Dictionary<string, string>();
private readonly Dictionary<string, string> keywordHighlights = new Dictionary<string, string>();
private readonly StringBuilder highlightBuilder = new StringBuilder();

View File

@ -243,6 +243,8 @@ namespace UnityExplorer.UI.CSConsole
}
HighlightVisibleInput();
UpdateCaret(out _);
}
public static void Update()
@ -260,7 +262,8 @@ namespace UnityExplorer.UI.CSConsole
if (!settingCaretCoroutine && EnableSuggestions && caretMoved)
{
Completer.CheckAutocompletes();
AutoCompleteModal.Instance.ReleaseOwnership(Completer);
//Completer.CheckAutocompletes();
}
if (EnableCtrlRShortcut