Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a610e27

Browse files
committed
Allow clearing of CodeLineEditingController's undo and redo stack #37
1 parent 6a26379 commit a610e27

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/src/_code_line.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,11 @@ class _CodeLineEditingControllerImpl extends ValueNotifier<CodeLineEditingValue>
10571057
);
10581058
}
10591059

1060+
@override
1061+
void clearHistory() {
1062+
_cache.clear();
1063+
}
1064+
10601065
@override
10611066
int index2lineIndex(int index) => codeLines.index2lineIndex(index);
10621067

@@ -1992,6 +1997,11 @@ class _CodeLineEditingCache {
19921997
}
19931998
}
19941999

2000+
void clear() {
2001+
_node = _CodeLineEditingCacheNode(controller.value);
2002+
_markNewRecord = false;
2003+
}
2004+
19952005
void dispose() {
19962006
controller.removeListener(_onValueChanged);
19972007
}
@@ -2189,6 +2199,11 @@ class _CodeLineEditingControllerDelegate implements CodeLineEditingController {
21892199
_delegate.clearComposing();
21902200
}
21912201

2202+
@override
2203+
void clearHistory() {
2204+
_delegate.clearHistory();
2205+
}
2206+
21922207
@override
21932208
void collapseChunk(int index, int end) {
21942209
_delegate.collapseChunk(index, end);

lib/src/code_line.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,9 @@ abstract class CodeLineEditingController extends ValueNotifier<CodeLineEditingVa
331331
/// actions, not during the build, layout, or paint phases.
332332
void clearComposing();
333333

334+
/// Clear the undo and redo history.
335+
void clearHistory();
336+
334337
/// Collapse codes form [start] to [end].
335338
void collapseChunk(int start, int end);
336339

0 commit comments

Comments
 (0)