Fixing range error bug

This commit is contained in:
Atila Neves 2015-06-16 12:08:08 +02:00
parent 17053fab06
commit c103417cae
1 changed files with 6 additions and 3 deletions

View File

@ -229,10 +229,13 @@ AutocompleteResponse dotCompletion(T)(T beforeTokens,
// responses when the cursor is in the middle of an identifier instead // responses when the cursor is in the middle of an identifier instead
// of at the end // of at the end
auto t = beforeTokens[$ - 1]; auto t = beforeTokens[$ - 1];
partial = t.text[0 .. cursorPosition - t.index]; if (cursorPosition - t.index >= 0 && cursorPosition - t.index < t.text.length)
{
partial = t.text[0 .. cursorPosition - t.index];
significantTokenType = tok!"identifier"; significantTokenType = tok!"identifier";
beforeTokens = beforeTokens[0 .. $ - 1]; beforeTokens = beforeTokens[0 .. $ - 1];
}
} }
else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == tok!".") else if (beforeTokens.length >= 2 && beforeTokens[$ - 1] == tok!".")
significantTokenType = beforeTokens[$ - 2].type; significantTokenType = beforeTokens[$ - 2].type;