From dffaf8d75e3110db8fd967c44feffb4876864886 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 19 Sep 2016 16:27:33 +0200 Subject: [PATCH] remove dittos from the results of the ddoc query, close #325 --- src/server/autocomplete.d | 11 ++++++++++- tests/tc044/expected.txt | 1 + tests/tc044/file.d | 1 + tests/tc044/run.sh | 8 ++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/tc044/expected.txt create mode 100644 tests/tc044/file.d create mode 100755 tests/tc044/run.sh diff --git a/src/server/autocomplete.d b/src/server/autocomplete.d index 4c3c1a6..fb386a3 100644 --- a/src/server/autocomplete.d +++ b/src/server/autocomplete.d @@ -73,6 +73,15 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request, { Appender!(char[]) app; + bool isDitto(string s) + { + import std.uni : icmp; + if (s.length > 5) + return false; + else + return s.icmp("ditto") == 0; + } + void putDDocChar(dchar c) { switch (c) @@ -97,7 +106,7 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request, putDDocChar(c); } - foreach(symbol; stuff.symbols.filter!(a => !a.doc.empty)) + foreach(ref symbol; stuff.symbols.filter!(a => !a.doc.empty && !isDitto(a.doc))) { app.clear; putDDocString(symbol.doc); diff --git a/tests/tc044/expected.txt b/tests/tc044/expected.txt new file mode 100644 index 0000000..4bcfe98 --- /dev/null +++ b/tests/tc044/expected.txt @@ -0,0 +1 @@ +d diff --git a/tests/tc044/file.d b/tests/tc044/file.d new file mode 100644 index 0000000..4456cd1 --- /dev/null +++ b/tests/tc044/file.d @@ -0,0 +1 @@ +/**d*/void fun(){} /**ditto*/void fun(uint){} /** ditto */void fun(float){} \ No newline at end of file diff --git a/tests/tc044/run.sh b/tests/tc044/run.sh new file mode 100755 index 0000000..2b5050c --- /dev/null +++ b/tests/tc044/run.sh @@ -0,0 +1,8 @@ +set -e +set -u + +../../bin/dcd-client $1 file.d -c12 -d > actual.txt +diff actual.txt expected.txt + +../../bin/dcd-client $1 file.d -c35 -d > actual.txt +diff actual.txt expected.txt \ No newline at end of file