Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit d150ff3

Browse files
committed
Fix minor issues with CSConsole delimiter logic
1 parent c4fa0d6 commit d150ff3

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

src/UI/CSConsole/CSAutoCompleter.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void CheckAutocompletes()
4141
suggestions.Clear();
4242

4343
int caret = Math.Max(0, Math.Min(InputField.Text.Length - 1, InputField.Component.caretPosition - 1));
44-
int start = caret;
44+
int startIdx = caret;
4545

4646
// If the character at the caret index is whitespace or delimiter,
4747
// or if the next character (if it exists) is not whitespace,
@@ -55,17 +55,20 @@ public void CheckAutocompletes()
5555
}
5656

5757
// get the current composition string (from caret back to last delimiter)
58-
while (start > 0)
58+
while (startIdx > 0)
5959
{
60-
start--;
61-
char c = InputField.Text[start];
60+
startIdx--;
61+
char c = InputField.Text[startIdx];
6262
if (delimiters.Contains(c))
6363
{
64-
start++;
64+
startIdx++;
65+
while (char.IsWhiteSpace(InputField.Text[startIdx]))
66+
startIdx++;
6567
break;
6668
}
6769
}
68-
string input = InputField.Text.Substring(start, caret - start + 1);
70+
string input = InputField.Text.Substring(startIdx, caret - startIdx + 1);
71+
6972

7073
// Get MCS completions
7174

src/UI/CSConsole/Lexers/KeywordLexer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public override bool TryMatchCurrent(LexerBuilder lexer)
4141
while (!lexer.EndOfInput && char.IsLetter(lexer.PeekNext()))
4242
sb.Append(lexer.Current);
4343

44+
// next must be whitespace or delimiter
45+
if (!lexer.EndOfInput && !(char.IsWhiteSpace(lexer.Current) || lexer.IsDelimiter(lexer.Current)))
46+
return false;
47+
4448
if (keywords.Contains(sb.ToString()))
4549
{
4650
if (!lexer.EndOfInput)

src/UI/CSConsole/Lexers/SymbolLexer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class SymbolLexer : Lexer
1111
protected override Color HighlightColor => new Color(0.6f, 0.6f, 0.6f);
1212

1313
// all symbols are delimiters
14-
public override IEnumerable<char> Delimiters => symbols;
14+
public override IEnumerable<char> Delimiters => symbols.Where(it => it != '.'); // '.' is not a delimiter, only a separator.
1515

1616
public static bool IsSymbol(char c) => symbols.Contains(c);
1717

0 commit comments

Comments
 (0)