Skip to content

Commit 3b89f13

Browse files
committed
Add onUpdate option (experimental, not documented yet)
1 parent deba509 commit 3b89f13

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/codemirror.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ var CodeMirror = (function() {
790790
// Uses a set of changes plus the current scroll position to
791791
// determine which DOM updates have to be made, and makes the
792792
// updates.
793-
function updateDisplay(changes) {
793+
function updateDisplay(changes, suppressCallback) {
794794
if (!scroller.clientWidth) {
795795
showingFrom = showingTo = displayOffset = 0;
796796
return;
@@ -865,6 +865,8 @@ var CodeMirror = (function() {
865865
gutter.style.display = gutterDisplay;
866866
if (different || gutterDirty) updateGutter();
867867
updateCursor();
868+
if (!suppressCallback && options.onUpdate) options.onUpdate(instance);
869+
return true;
868870
}
869871

870872
function computeIntact(intact, changes) {
@@ -1650,9 +1652,9 @@ var CodeMirror = (function() {
16501652
changes = []; selectionChanged = false; callbacks = [];
16511653
}
16521654
function endOperation() {
1653-
var reScroll = false;
1655+
var reScroll = false, updated;
16541656
if (selectionChanged) reScroll = !scrollCursorIntoView();
1655-
if (changes.length) updateDisplay(changes);
1657+
if (changes.length) updated = updateDisplay(changes, true);
16561658
else {
16571659
if (selectionChanged) updateCursor();
16581660
if (gutterDirty) updateGutter();
@@ -1675,6 +1677,7 @@ var CodeMirror = (function() {
16751677
if (tc && options.onChange && instance)
16761678
options.onChange(instance, tc);
16771679
for (var i = 0; i < cbs.length; ++i) cbs[i](instance);
1680+
if (updated && options.onUpdate) options.onUpdate(instance);
16781681
}
16791682
var nestedOperation = 0;
16801683
function operation(f) {

0 commit comments

Comments
 (0)