From 5244f8136736eee3f7b6d9433754c6cce7f88e31 Mon Sep 17 00:00:00 2001 From: ryuukk <44361234+ryuukk@users.noreply.github.com> Date: Tue, 14 Nov 2023 14:59:08 +0100 Subject: [PATCH] Add support for extended output when requesting symbol's documentation (#757) --- src/dcd/client/client.d | 12 ++++++++---- src/dcd/server/autocomplete/doc.d | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dcd/client/client.d b/src/dcd/client/client.d index e0be61d5..bd619d98 100644 --- a/src/dcd/client/client.d +++ b/src/dcd/client/client.d @@ -250,7 +250,7 @@ int runClient(string[] args) else if (getIdentifier) printIdentifierResponse(response); else if (doc) - printDocResponse(response); + printDocResponse(response, fullOutput); else if (search !is null) printSearchResponse(response); else if (localUse) @@ -359,10 +359,14 @@ Socket createSocket(string socketFile, ushort port) return socket; } -void printDocResponse(ref const AutocompleteResponse response) +void printDocResponse(ref const AutocompleteResponse response, bool extended) { - import std.algorithm : each; - response.completions.each!(a => a.documentation.escapeConsoleOutputString(true).writeln); + foreach (ref completion; response.completions) + { + if (extended) + writeln(completion.definition); + writeln(completion.documentation.escapeConsoleOutputString(true)); + } } void printIdentifierResponse(ref const AutocompleteResponse response) diff --git a/src/dcd/server/autocomplete/doc.d b/src/dcd/server/autocomplete/doc.d index 060ba30a..c3dbc1db 100644 --- a/src/dcd/server/autocomplete/doc.d +++ b/src/dcd/server/autocomplete/doc.d @@ -62,7 +62,7 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request, continue; firstSymbol = false; - AutocompleteResponse.Completion c; + AutocompleteResponse.Completion c = makeSymbolCompletionInfo(symbol, symbol.kind); c.documentation = symbol.doc; response.completions ~= c; }