Merge pull request #312 from CyberShadow/pull-20160326-044358-issue-311

Fix issue #311 (Ambiguous newlines in --doc output)
This commit is contained in:
Brian Schott 2016-03-25 20:15:59 -07:00
commit afc2d55dbc
5 changed files with 18 additions and 1 deletions

View File

@ -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

View File

@ -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');

View File

@ -0,0 +1 @@
This is not a newline: \\n But this is:\nThis is not a newline either: $(D '\\n')

View File

@ -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;
}

View File

@ -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