Commit 952b7549 by Bridger Maxwell

New method works without line wrapping too

parent 5580c62e
...@@ -697,8 +697,8 @@ var CodeMirror = (function() { ...@@ -697,8 +697,8 @@ var CodeMirror = (function() {
// Add these lines to the work array, so that they will be // Add these lines to the work array, so that they will be
// highlighted. Adjust work lines if lines were added/removed. // highlighted. Adjust work lines if lines were added/removed.
var newWork = [], lendiff = newText.length - nlines - 1; var newWork = [], lendiff = newText.length - nlines - 1;
for (var i = 0, l = work.length; i < l; ++i) { for (var j = 0, l = work.length; j < l; ++j) {
var task = work[i]; var task = work[j];
if (task < from.line) newWork.push(task); if (task < from.line) newWork.push(task);
else if (task > to.line) newWork.push(task + lendiff); else if (task > to.line) newWork.push(task + lendiff);
} }
...@@ -727,12 +727,16 @@ var CodeMirror = (function() { ...@@ -727,12 +727,16 @@ var CodeMirror = (function() {
}); });
} else { } else {
//TODO: update height here for widget blocks //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; var l = line.text;
if (l.length > maxLineLength) { if (l.length > maxLineLength) {
maxLine = l; maxLineLength = l.length; maxWidth = null; maxLine = l; maxLineLength = l.length; maxWidth = null;
recomputeMaxLength = false; recomputeMaxLength = false;
} }
if (line.isWidgetBlock) {
var guess = line.styles[1].size(line.text).height / textHeight();
if (guess != line.height) updateLineHeight(line, guess);
}
}); });
if (recomputeMaxLength) { if (recomputeMaxLength) {
maxLineLength = 0; maxLine = ""; maxWidth = null; maxLineLength = 0; maxLine = ""; maxWidth = null;
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
mode: 'mitx_markdown', mode: 'mitx_markdown',
matchBrackets: true, matchBrackets: true,
theme: "default", theme: "default",
lineWrapping: true, lineWrapping: false,
}); });
//Store the inital contents so we can compare for unsaved changes //Store the inital contents so we can compare for unsaved changes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment