mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-16 00:07:52 +08:00
Add namespace autocompletions, some adjustments to autocomplete logic
This commit is contained in:
@ -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();
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user