diff --git a/README.md b/README.md index bc2e64e..03a47fd 100644 --- a/README.md +++ b/README.md @@ -156,7 +156,7 @@ When run with the --doc or -d option, DCD will attempt to display documentation comments associated with the symbol at the cursor position. In the case of functions there can be more than one documentation comment associated with a symbol. One doc comment will be printed per line. Newlines within the doc -comments will be replaced with "\n". +comments will be replaced with "\n", and backslashes escaped as "\\". #### Example output An example doc comment\nParams: a = first param\n Returns: nothing An example doc comment\nParams: a = first param\n b = second param\n Returns: nothing diff --git a/src/server/autocomplete.d b/src/server/autocomplete.d index cc76f1b..260f546 100644 --- a/src/server/autocomplete.d +++ b/src/server/autocomplete.d @@ -88,6 +88,10 @@ public AutocompleteResponse getDoc(const AutocompleteRequest request, { switch (c) { + case '\\': + outputRange.put('\\'); + outputRange.put('\\'); + break; case '\n': outputRange.put('\\'); outputRange.put('n'); diff --git a/tests/tc024/expected8.txt b/tests/tc024/expected8.txt new file mode 100644 index 0000000..309bc59 --- /dev/null +++ b/tests/tc024/expected8.txt @@ -0,0 +1 @@ +This is not a newline: \\n But this is:\nThis is not a newline either: $(D '\\n') diff --git a/tests/tc024/file.d b/tests/tc024/file.d index 92d2fce..b298899 100644 --- a/tests/tc024/file.d +++ b/tests/tc024/file.d @@ -28,3 +28,12 @@ unittest g; cool; } + +/** This is not a newline: \n But this is: */ +/** This is not a newline either: $(D '\n') */ +int f; + +unittest +{ + f; +} diff --git a/tests/tc024/run.sh b/tests/tc024/run.sh index 71eeeb2..3ae2e0c 100755 --- a/tests/tc024/run.sh +++ b/tests/tc024/run.sh @@ -21,3 +21,6 @@ diff actual6.txt expected6.txt ../../bin/dcd-client $1 file.d -c313 -d> actual7.txt diff actual7.txt expected7.txt + +../../bin/dcd-client $1 file.d -c432 -d> actual8.txt +diff actual8.txt expected8.txt