prevent a range error, close #368

This commit is contained in:
Basile Burg 2017-04-07 17:26:44 +02:00
parent 4998a3c441
commit cb2074a152
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
3 changed files with 14 additions and 2 deletions

View File

@ -791,10 +791,14 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
//writeln("<<<");
//dumpTokens(tokens.release);
//writeln("<<<");
if (tokens.length == 0) // workaround (#371)
return [];
}
else if (tokens[0] == tok!"." && tokens.length > 1)
{
tokens = tokens[1 .. $];
if (tokens.length == 0) // workaround (#371)
return [];
symbols = completionScope.getSymbolsAtGlobalScope(stringToken(tokens[0]));
}
else
@ -802,8 +806,11 @@ DSymbol*[] getSymbolsByTokenChain(T)(Scope* completionScope,
if (symbols.length == 0)
{
//TODO: better bugfix for issue #368, see test case 52 or pull #371
if (tokens.length)
warning("Could not find declaration of ", stringToken(tokens[0]),
" from position ", cursorPosition);
else assert(0, "internal error");
return [];
}

1
tests/tc052/file.d Normal file
View File

@ -0,0 +1 @@
void main(){assert(te.caretRightText == "tà");}

4
tests/tc052/run.sh Executable file
View File

@ -0,0 +1,4 @@
set -e
set -u
../../bin/dcd-client $1 file.d -c46 -d