mirror of
https://github.com/dlang-community/DCD.git
synced 2025-04-25 21:00:02 +03:00
prevent a range error, close #368
This commit is contained in:
parent
4998a3c441
commit
cb2074a152
3 changed files with 14 additions and 2 deletions
|
@ -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)
|
||||
{
|
||||
warning("Could not find declaration of ", stringToken(tokens[0]),
|
||||
" from position ", cursorPosition);
|
||||
//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
1
tests/tc052/file.d
Normal file
|
@ -0,0 +1 @@
|
|||
void main(){assert(te.caretRightText == "tà");}
|
4
tests/tc052/run.sh
Executable file
4
tests/tc052/run.sh
Executable file
|
@ -0,0 +1,4 @@
|
|||
set -e
|
||||
set -u
|
||||
|
||||
../../bin/dcd-client $1 file.d -c46 -d
|
Loading…
Add table
Add a link
Reference in a new issue