From 952b75496630597d688ec8f43ecf8ffbea49f8f0 Mon Sep 17 00:00:00 2001 From: Bridger Maxwell Date: Mon, 26 Mar 2012 17:15:45 -0700 Subject: [PATCH] New method works without line wrapping too --- static/js/CodeMirror/codemirror.js | 10 +++++++--- templates/simplewiki_edit.html | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/static/js/CodeMirror/codemirror.js b/static/js/CodeMirror/codemirror.js index b6d2d21bdd..bc5927b831 100644 --- a/static/js/CodeMirror/codemirror.js +++ b/static/js/CodeMirror/codemirror.js @@ -697,8 +697,8 @@ var CodeMirror = (function() { // Add these lines to the work array, so that they will be // highlighted. Adjust work lines if lines were added/removed. var newWork = [], lendiff = newText.length - nlines - 1; - for (var i = 0, l = work.length; i < l; ++i) { - var task = work[i]; + for (var j = 0, l = work.length; j < l; ++j) { + var task = work[j]; if (task < from.line) newWork.push(task); else if (task > to.line) newWork.push(task + lendiff); } @@ -727,12 +727,16 @@ var CodeMirror = (function() { }); } else { //TODO: update height here for widget blocks - doc.iter(from.line, i + newText.length, function(line) { + doc.iter(from.line, from.line + newText.length, function(line) { var l = line.text; if (l.length > maxLineLength) { maxLine = l; maxLineLength = l.length; maxWidth = null; recomputeMaxLength = false; } + if (line.isWidgetBlock) { + var guess = line.styles[1].size(line.text).height / textHeight(); + if (guess != line.height) updateLineHeight(line, guess); + } }); if (recomputeMaxLength) { maxLineLength = 0; maxLine = ""; maxWidth = null; diff --git a/templates/simplewiki_edit.html b/templates/simplewiki_edit.html index 82c0456473..1c5ebd40fc 100644 --- a/templates/simplewiki_edit.html +++ b/templates/simplewiki_edit.html @@ -39,7 +39,7 @@ mode: 'mitx_markdown', matchBrackets: true, theme: "default", - lineWrapping: true, + lineWrapping: false, }); //Store the inital contents so we can compare for unsaved changes