Skip to content
Snippets Groups Projects
Commit d708748a authored by Marijn Haverbeke's avatar Marijn Haverbeke
Browse files

[hardwrap demo] Make less prone to infinite loops

Issue #3548
parent eac55859
No related branches found
Tags 3.15.0
No related merge requests found
...@@ -60,11 +60,14 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), { ...@@ -60,11 +60,14 @@ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
"Ctrl-Q": function(cm) { cm.wrapParagraph(cm.getCursor(), options); } "Ctrl-Q": function(cm) { cm.wrapParagraph(cm.getCursor(), options); }
} }
}); });
var wait, options = {column: 60}; var wait, options = {column: 60}, changing = false;
editor.on("change", function(cm, change) { editor.on("change", function(cm, change) {
if (changing) return;
clearTimeout(wait); clearTimeout(wait);
wait = setTimeout(function() { wait = setTimeout(function() {
console.log(cm.wrapParagraphsInRange(change.from, CodeMirror.changeEnd(change), options)); changing = true;
cm.wrapParagraphsInRange(change.from, CodeMirror.changeEnd(change), options);
changing = false;
}, 200); }, 200);
}); });
</script> </script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment