commit | 36a31879da14f8085152c68b2584b517e391b7f7 | [log] [tgz] |
---|---|---|
author | Brian Wilkerson <brianwilkerson@google.com> | Mon Feb 11 01:31:59 2019 +0000 |
committer | commit-bot@chromium.org <commit-bot@chromium.org> | Mon Feb 11 01:31:59 2019 +0000 |
tree | 8176030a23da687dfe961c3412b99d51803d3533 | |
parent | 6875b9b26b06480b097b923e7617618161de82f8 [diff] |
Preserve indentation when converting documentation from block to line Change-Id: I2528b73aaea23d85c397d2199b6f5f9706809c3c Reviewed-on: https://dart-review.googlesource.com/c/92536 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart index dc17318..dcd8855 100644 --- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart +++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -649,11 +649,11 @@ _coverageMarker(); return; } - line = line.substring(expectedPrefix.length).trim(); + line = line.substring(expectedPrefix.length); if (line.isEmpty) { newLines.add('$linePrefix///'); } else { - newLines.add('$linePrefix/// $line'); + newLines.add('$linePrefix///$line'); } linePrefix = eol + prefix; }
diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart index 535bf55..b13e269 100644 --- a/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart +++ b/pkg/analysis_server/test/src/services/correction/assist/convert_documentation_into_line_test.dart
@@ -109,4 +109,25 @@ } '''); } + + test_preserveIndentation() async { + await resolveTestUnit(''' +class A { + /** + * First line. + * Indented line. + * Last line. + */ + m() {} +} +'''); + await assertHasAssistAt('Indented', ''' +class A { + /// First line. + /// Indented line. + /// Last line. + m() {} +} +'''); + } }