Skip to content

Commit

Permalink
Remove premature, harmful optimization in indentLine
Browse files Browse the repository at this point in the history
Closes #646
  • Loading branch information
marijnh committed Jul 20, 2012
1 parent 62a2cdb commit d2a1825
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions lib/codemirror.js
Expand Up @@ -1475,15 +1475,10 @@ var CodeMirror = (function() {
indentation = Math.max(0, indentation);
var diff = indentation - curSpace;

if (!diff) {
if (sel.from.line != n && sel.to.line != n) return;
var indentString = curSpaceString;
} else {
var indentString = "", pos = 0;
if (options.indentWithTabs)
for (var i = Math.floor(indentation / options.tabSize); i; --i) {pos += options.tabSize; indentString += "\t";}
while (pos < indentation) {++pos; indentString += " ";}
}
var indentString = "", pos = 0;
if (options.indentWithTabs)
for (var i = Math.floor(indentation / options.tabSize); i; --i) {pos += options.tabSize; indentString += "\t";}
while (pos < indentation) {++pos; indentString += " ";}

replaceRange(indentString, {line: n, ch: 0}, {line: n, ch: curSpaceString.length});
}
Expand Down
2 changes: 1 addition & 1 deletion mode/xml/xml.js
Expand Up @@ -312,7 +312,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
if (a.indented != b.indented || a.tokenize != b.tokenize) return false;
for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
if (!ca || !cb) return ca == cb;
if (ca.tagName != cb.tagName) return false;
if (ca.tagName != cb.tagName || ca.indent != cb.indent) return false;
}
},

Expand Down

0 comments on commit d2a1825

Please sign in to comment.