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

Unified Diff: lib/src/source_visitor.dart

Issue 840113002: Handle Windows line endings in multi-line strings. Fix #126. (Closed) Base URL: https://github.com/dart-lang/dart_style.git@master
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 | « CHANGELOG.md ('k') | test/formatter_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/source_visitor.dart
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index 540735d920f5de14c4f32a8dc5dced01229dd9fb..0a228f70639a3fad31244e8991776b50de2bc97d 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -15,6 +15,8 @@ import 'whitespace.dart';
/// An AST visitor that drives formatting heuristics.
class SourceVisitor implements AstVisitor {
+ final DartFormatter _formatter;
+
/// The writer to which the output lines are written.
final LineWriter _writer;
@@ -34,8 +36,9 @@ class SourceVisitor implements AstVisitor {
/// Initialize a newly created visitor to write source code representing
/// the visited nodes to the given [writer].
- SourceVisitor(DartFormatter formatter, this._lineInfo, SourceCode source)
- : _source = source,
+ SourceVisitor(formatter, this._lineInfo, SourceCode source)
+ : _formatter = formatter,
+ _source = source,
_writer = new LineWriter(formatter, source);
/// Runs the visitor on [node], formatting its contents.
@@ -1589,7 +1592,7 @@ class SourceVisitor implements AstVisitor {
/// can handle them correctly.
void _writeStringLiteral(String string, int offset) {
// Split each line of a multiline string into separate chunks.
- var lines = string.split("\n");
+ var lines = string.split(_formatter.lineEnding);
_writeText(lines.first, offset);
offset += lines.first.length;
« no previous file with comments | « CHANGELOG.md ('k') | test/formatter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698