Skip to content

Commit

Permalink
Fix after review (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyinkin committed Oct 31, 2022
1 parent 0c23cc6 commit 78a0ee9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
14 changes: 0 additions & 14 deletions lib/src/code_field/text_editing_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,4 @@ extension TextEditingValueExtension on TextEditingValue {
}
return text.substring(selection.end);
}

// These are used in tests only.

TextEditingValue replacedSelection(String text) {
return replaced(selection, text);
}

TextEditingValue typed(String text) {
final lengthDiff = text.length - selected.length;

return replaced(selection, text).copyWith(
selection: TextSelection.collapsed(offset: selection.end + lengthDiff),
);
}
}
2 changes: 1 addition & 1 deletion test/src/code_field/code_controller_folding_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_code_editor/src/code_field/text_editing_value.dart';
import 'package:flutter_test/flutter_test.dart';

import '../common/create_app.dart';
import '../common/text_editing_value.dart';
import '../common/widget_tester.dart';

const _code = '''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:highlight/languages/java.dart';

import '../common/create_app.dart';
import '../common/text_editing_value.dart';

const _text = '''
// [START section2]
Expand Down
1 change: 1 addition & 0 deletions test/src/code_field/code_controller_readonly_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:highlight/languages/java.dart';

import '../common/create_app.dart';
import '../common/text_editing_value.dart';

const _editableBeginningEnd = '''
abc
Expand Down
16 changes: 16 additions & 0 deletions test/src/common/text_editing_value.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_code_editor/flutter_code_editor.dart';

extension TextEditingValueTestExtension on TextEditingValue {
TextEditingValue replacedSelection(String text) {
return replaced(selection, text);
}

TextEditingValue typed(String text) {
final lengthDiff = text.length - selected.length;

return replaced(selection, text).copyWith(
selection: TextSelection.collapsed(offset: selection.end + lengthDiff),
);
}
}
1 change: 1 addition & 0 deletions test/src/history/code_history_controller_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter_test/flutter_test.dart';

import '../common/create_app.dart';
import '../common/snippets.dart';
import '../common/text_editing_value.dart';
import '../common/widget_tester.dart';

void main() {
Expand Down

0 comments on commit 78a0ee9

Please sign in to comment.