mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-06 01:23:31 +08:00
Fix minor issues with CSConsole delimiter logic
This commit is contained in:
parent
c4fa0d6bcd
commit
d150ff3455
@ -41,7 +41,7 @@ namespace UnityExplorer.UI.CSConsole
|
||||
suggestions.Clear();
|
||||
|
||||
int caret = Math.Max(0, Math.Min(InputField.Text.Length - 1, InputField.Component.caretPosition - 1));
|
||||
int start = caret;
|
||||
int startIdx = caret;
|
||||
|
||||
// If the character at the caret index is whitespace or delimiter,
|
||||
// or if the next character (if it exists) is not whitespace,
|
||||
@ -55,17 +55,20 @@ namespace UnityExplorer.UI.CSConsole
|
||||
}
|
||||
|
||||
// get the current composition string (from caret back to last delimiter)
|
||||
while (start > 0)
|
||||
while (startIdx > 0)
|
||||
{
|
||||
start--;
|
||||
char c = InputField.Text[start];
|
||||
startIdx--;
|
||||
char c = InputField.Text[startIdx];
|
||||
if (delimiters.Contains(c))
|
||||
{
|
||||
start++;
|
||||
startIdx++;
|
||||
while (char.IsWhiteSpace(InputField.Text[startIdx]))
|
||||
startIdx++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
string input = InputField.Text.Substring(start, caret - start + 1);
|
||||
string input = InputField.Text.Substring(startIdx, caret - startIdx + 1);
|
||||
|
||||
|
||||
// Get MCS completions
|
||||
|
||||
|
@ -41,6 +41,10 @@ namespace UnityExplorer.UI.CSConsole.Lexers
|
||||
while (!lexer.EndOfInput && char.IsLetter(lexer.PeekNext()))
|
||||
sb.Append(lexer.Current);
|
||||
|
||||
// next must be whitespace or delimiter
|
||||
if (!lexer.EndOfInput && !(char.IsWhiteSpace(lexer.Current) || lexer.IsDelimiter(lexer.Current)))
|
||||
return false;
|
||||
|
||||
if (keywords.Contains(sb.ToString()))
|
||||
{
|
||||
if (!lexer.EndOfInput)
|
||||
|
@ -11,7 +11,7 @@ namespace UnityExplorer.UI.CSConsole.Lexers
|
||||
protected override Color HighlightColor => new Color(0.6f, 0.6f, 0.6f);
|
||||
|
||||
// all symbols are delimiters
|
||||
public override IEnumerable<char> Delimiters => symbols;
|
||||
public override IEnumerable<char> Delimiters => symbols.Where(it => it != '.'); // '.' is not a delimiter, only a separator.
|
||||
|
||||
public static bool IsSymbol(char c) => symbols.Contains(c);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user