fix --localUse off-by-one error (#640)

This commit is contained in:
Jan Jurzitza 2021-07-14 20:41:41 +02:00 committed by GitHub
parent 8dce131a8e
commit 46ea058cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -84,8 +84,8 @@ public AutocompleteResponse findLocalUse(AutocompleteRequest request,
{
if (t.type != tok!"identifier")
continue;
if (request.cursorPosition >= t.index &&
request.cursorPosition < t.index + t.text.length)
if (request.cursorPosition > t.index &&
request.cursorPosition <= t.index + t.text.length)
{
sourceToken = tokenArray.ptr + i;
break;

View File

@ -3,3 +3,7 @@ set -u
../../bin/dcd-client $1 file.d -u -c22 | sed s\""$(dirname "$(pwd)")"\"\" > actual1.txt
diff actual1.txt expected1.txt
# should work on last character of identifier
../../bin/dcd-client $1 file.d -u -c24 | sed s\""$(dirname "$(pwd)")"\"\" > actual2.txt
diff actual2.txt expected1.txt