| Index: pkg/analysis_server/lib/src/edit/edit_domain.dart
|
| ===================================================================
|
| --- pkg/analysis_server/lib/src/edit/edit_domain.dart (revision 43367)
|
| +++ pkg/analysis_server/lib/src/edit/edit_domain.dart (working copy)
|
| @@ -73,14 +73,24 @@
|
| } catch (e) {
|
| return new Response.formatInvalidFile(request);
|
| }
|
| +
|
| String unformattedSource = contents.data;
|
|
|
| + int start = params.selectionOffset;
|
| + int length = params.selectionLength;
|
| +
|
| + // No need to preserve 0,0 selection
|
| + if (start == 0 && length == 0) {
|
| + start = null;
|
| + length = null;
|
| + }
|
| +
|
| SourceCode code = new SourceCode(
|
| unformattedSource,
|
| uri: null,
|
| isCompilationUnit: true,
|
| - selectionStart: params.selectionOffset,
|
| - selectionLength: params.selectionLength);
|
| + selectionStart: start,
|
| + selectionLength: length);
|
| DartFormatter formatter = new DartFormatter();
|
| SourceCode formattedResult = formatter.formatSource(code);
|
| String formattedSource = formattedResult.text;
|
|
|