From 292f3bae068648a46e0cef56800d7f0c57e57d6d Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 29 Dec 2018 14:29:37 +0100 Subject: [PATCH] fix issue 557 - Module name completion should not complete anything --- src/dcd/server/autocomplete/complete.d | 7 ++++--- tests/tc_currmod_fqn/expected3.txt | 0 tests/tc_currmod_fqn/file3.d | 1 + tests/tc_currmod_fqn/run.sh | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 tests/tc_currmod_fqn/expected3.txt create mode 100644 tests/tc_currmod_fqn/file3.d diff --git a/src/dcd/server/autocomplete/complete.d b/src/dcd/server/autocomplete/complete.d index 82484c1..192361f 100644 --- a/src/dcd/server/autocomplete/complete.d +++ b/src/dcd/server/autocomplete/complete.d @@ -77,10 +77,11 @@ public AutocompleteResponse complete(const AutocompleteRequest request, if (tokenArray.length >= 3 && tokenArray[0] == tok!"module" && beforeTokens.length && (beforeTokens[$-1] == tok!"." || dotId)) { - const upper = tokenArray.countUntil!(a => a.type == tok!";"); - bool isSame = true; + const upper = tokenArray.countUntil!(a => a.type == tok!";" && + a.index < beforeTokens[$-1].index); + bool isSame = upper != -1; // enough room for the module decl and the fqn... - if (upper != -1 && beforeTokens.length >= upper * 2) + if (isSame && beforeTokens.length >= upper * 2) foreach (immutable i; 0 .. upper) { const j = beforeTokens.length - upper + i - 1 - ubyte(dotId); diff --git a/tests/tc_currmod_fqn/expected3.txt b/tests/tc_currmod_fqn/expected3.txt new file mode 100644 index 0000000..e69de29 diff --git a/tests/tc_currmod_fqn/file3.d b/tests/tc_currmod_fqn/file3.d new file mode 100644 index 0000000..3434989 --- /dev/null +++ b/tests/tc_currmod_fqn/file3.d @@ -0,0 +1 @@ +module foo.test; int x; diff --git a/tests/tc_currmod_fqn/run.sh b/tests/tc_currmod_fqn/run.sh index 7e121c8..322de93 100755 --- a/tests/tc_currmod_fqn/run.sh +++ b/tests/tc_currmod_fqn/run.sh @@ -5,3 +5,5 @@ set -u diff actual1.txt expected1.txt ../../bin/dcd-client $1 file2.d -c46 > actual2.txt diff actual2.txt expected2.txt +../../bin/dcd-client $1 file3.d -c11 > actual3.txt +diff actual3.txt expected3.txt