Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Unified Diff: pkg/analysis_server/lib/src/edit/edit_domain.dart

Issue 894863002: Formatter service API tweaks. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/lib/src/generated_protocol.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « pkg/analysis_server/doc/api.html ('k') | pkg/analysis_server/lib/src/generated_protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698