public void RefreshTokenInfo(bool force = false)
{
if(hasFreshTokens && force == false)
{
return;
}
Tokens = Tokenizer.Tokenize(new ConsoleString(Buffer).ToString());
if (Tokens.Count == 0)
{
Tokens.Add(new Token("", 0, 1, 1));
}
CurrentToken = null;
for (int i = 0; i < Tokens.Count; i++)
{
var token = Tokens[i];
if (BufferPosition < token.EndIndex && BufferPosition >= token.StartIndex)
{
// BUFFER---------: a command line string
// BUFFER POSITION: [ ]
CurrentToken = token;
CurrentTokenIndex = i;
break;
}
}
if(CurrentToken == null)
{
CurrentToken = Tokens[Tokens.Count - 1];
CurrentTokenIndex = Tokens.Count - 1;
}
}