Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83f0e9d079 |
No files matched your search
@@ -8,7 +8,6 @@ const CodeLines _kInitialCodeLines = CodeLines([
|
||||
|
||||
const int _kUnitCodeWhitespace = 0x20;
|
||||
const List<String> _kClosures = ['{}', '[]', '()'];
|
||||
const List<String> _kClosureAndQuates = ['{}', '[]', '()', '\'\'', '""', '``'];
|
||||
|
||||
class _CodeLineEditingControllerImpl extends ValueNotifier<CodeLineEditingValue> implements CodeLineEditingController {
|
||||
|
||||
@@ -1312,20 +1311,6 @@ class _CodeLineEditingControllerImpl extends ValueNotifier<CodeLineEditingValue>
|
||||
}
|
||||
} else {
|
||||
final CodeLines newCodeLines = CodeLines.from(codeLines);
|
||||
if (_isWrapedByClosureSymbol(baseLine.text, selection.baseOffset)) {
|
||||
// Delete left and right closure symbols at same time, like this:
|
||||
// abc{|}123 -> abc123
|
||||
newCodeLines[selection.baseIndex] = baseLine.copyWith(
|
||||
text: baseLine.substring(0, selection.baseOffset - 1) + baseLine.substring(selection.baseOffset + 1)
|
||||
);
|
||||
value = value.copyWith(
|
||||
codeLines: newCodeLines,
|
||||
selection: CodeLineSelection.collapsed(
|
||||
index: selection.baseIndex,
|
||||
offset: selection.baseOffset - 1
|
||||
)
|
||||
);
|
||||
} else {
|
||||
String backward = _codeTextBefore(selection.base);
|
||||
if (_isMultipleIndent(backward)) {
|
||||
// Delete a indent
|
||||
@@ -1346,7 +1331,6 @@ class _CodeLineEditingControllerImpl extends ValueNotifier<CodeLineEditingValue>
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
_deleteSelection();
|
||||
}
|
||||
@@ -1913,16 +1897,6 @@ class _CodeLineEditingControllerImpl extends ValueNotifier<CodeLineEditingValue>
|
||||
return count;
|
||||
}
|
||||
|
||||
bool _isWrapedByClosureSymbol(String text, int offset) {
|
||||
if (text.isEmpty) {
|
||||
return false;
|
||||
}
|
||||
if (offset - 1 < 0 || offset + 1 > text.length) {
|
||||
return false;
|
||||
}
|
||||
return _kClosureAndQuates.contains(text.substring(offset - 1, offset + 1));
|
||||
}
|
||||
|
||||
bool _isMultipleIndent(String text) => text.isNotEmpty && text.length % indent.length == 0
|
||||
&& _prefixWhitespaceCount(text) == text.length;
|
||||
|
||||
|
||||
@@ -2234,14 +2234,14 @@ void main() {
|
||||
controller.codeLines = CodeLines.of(const [
|
||||
CodeLine('abc{}')
|
||||
]);
|
||||
// Delete the {} at same time
|
||||
// Delete only previous character '{' (no paired bracket deletion)
|
||||
controller.selection = const CodeLineSelection.collapsed(
|
||||
index: 0,
|
||||
offset: 4
|
||||
);
|
||||
controller.deleteBackward();
|
||||
expect(controller.codeLines, CodeLines.of(const [
|
||||
CodeLine('abc')
|
||||
CodeLine('abc}')
|
||||
]));
|
||||
expect(controller.selection, const CodeLineSelection.collapsed(
|
||||
index: 0,
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ name: code_editor
|
||||
description: "A new Flutter project."
|
||||
publish_to: 'none'
|
||||
|
||||
version: 1.0.1+2
|
||||
version: 1.0.2+3
|
||||
|
||||
environment:
|
||||
sdk: ^3.9.2
|
||||
|
||||
Reference in new issue
Block a user