diff --git a/lib/codemirror.js b/lib/codemirror.js index ebaa643cbe..8aadebac78 100644 --- a/lib/codemirror.js +++ b/lib/codemirror.js @@ -880,7 +880,8 @@ var CodeMirror = (function() { } else if (how == "smart") indentation = mode.indent(state, line.text.slice(curSpaceString.length)); else if (how == "add") indentation = curSpace + options.indentUnit; - else if (how == "subtract") indentation = Math.max(0, curSpace - options.indentUnit); + else if (how == "subtract") indentation = curSpace - options.indentUnit; + indentation = Math.max(0, indentation); var diff = indentation - curSpace; if (!diff) { diff --git a/mode/clike/clike.js b/mode/clike/clike.js index b6517c2bbc..25bd791440 100644 --- a/mode/clike/clike.js +++ b/mode/clike/clike.js @@ -102,7 +102,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) { startState: function(basecolumn) { return { tokenize: tokenBase, - context: new Context((basecolumn || 0) - indentUnit, "top", false), + context: new Context((basecolumn || 0) - indentUnit, 0, "top", false), indented: 0, startOfLine: true };