warn about bad cursor position

This commit is contained in:
Basile Burg 2018-02-24 13:41:05 +01:00
parent 7e70c26faa
commit b646dd4680
1 changed files with 6 additions and 1 deletions

View File

@ -120,7 +120,12 @@ AutocompleteResponse dotCompletion(T)(T beforeTokens, const(Token)[] tokenArray,
// since later there's a non-nothrow call to `toUpper`
import std.utf : validate, UTFException;
try validate(partial);
catch (UTFException) partial = "";
catch (UTFException)
{
import std.experimental.logger : warning;
warning("cursor positioned within a UTF sequence");
partial = "";
}
}
significantTokenType = partial.length ? tok!"identifier" : tok!"";
beforeTokens = beforeTokens[0 .. $ - 1];