Fix reparent on windows

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2892963002 .
This commit is contained in:
Steve Messick 2017-05-19 10:28:42 -07:00
parent a8dc041543
commit 5455f21565
2 changed files with 54 additions and 3 deletions

View file

@ -1770,10 +1770,12 @@ class AssistProcessor {
sb.append('(');
if (newExprSrc.contains(eol)) {
int newlineIdx = newExprSrc.lastIndexOf(eol);
if (newlineIdx == newExprSrc.length - 1) {
newlineIdx -= 1;
int eolLen = eol.length;
if (newlineIdx == newExprSrc.length - eolLen) {
newlineIdx -= eolLen;
}
String indentOld = utils.getLinePrefix(newExpr.offset + 1 + newlineIdx);
String indentOld =
utils.getLinePrefix(newExpr.offset + eolLen + newlineIdx);
String indentNew = '$indentOld${utils.getIndent(1)}';
sb.append(eol);
sb.append(indentNew);

View file

@ -3994,6 +3994,55 @@ class FakeFlutter {
''');
}
test_reparentFlutterWidget_OK_multiLines_eol2() async {
_configureFlutterPkg({
'src/widgets/framework.dart': flutter_framework_code,
});
await resolveTestUnit('''
import 'package:flutter/src/widgets/framework.dart';\r
class FakeFlutter {\r
main() {\r
return new Container(\r
// start\r
child: new /*caret*/DefaultTextStyle(\r
child: new Row(\r
children: <Widget>[\r
new Container(\r
),\r
],\r
),\r
),\r
// end\r
);\r
}\r
}\r
''');
_setCaretLocation();
await assertHasAssist(
DartAssistKind.REPARENT_FLUTTER_WIDGET,
'''
import 'package:flutter/src/widgets/framework.dart';\r
class FakeFlutter {\r
main() {\r
return new Container(\r
// start\r
child: new widget(\r
child: new /*caret*/DefaultTextStyle(\r
child: new Row(\r
children: <Widget>[\r
new Container(\r
),\r
],\r
),\r
),\r
),\r
// end\r
);\r
}\r
}\r
''');
}
test_reparentFlutterWidget_OK_singleLine1() async {
_configureFlutterPkg({
'src/widgets/framework.dart': flutter_framework_code,