CodeMirror 2: Multiple indent is deleting lines

codemirror, javascript

Solution

The CodeMirror javascripts differ between your version and the demo version:

In the demo version at around line 2036 there is the following code block that is missing from your version:

defaultTab: function(cm) {
    if (cm.somethingSelected()) cm.indentSelection("add");
    else cm.replaceSelection("\t", "end");
}

Along with a bunch of functions related to `CodeMirror.keyMap`.

Compare the two and merge the missing bits, or just use the script from the demo version.

Problem

I have implemented Code Mirror as a plugin into a CMS system. I have an issue where if I select multiple lines and press tab the lines are deleted. This does not happen on the Code Mirror demo website. I can't find a configuration option to enable or disable multiple indent. Here is my configuration code: ``` this.CodeArea = CodeMirror.fromTextArea(codeArea, { lineNumbers: true, mode: { name: "xml", htmlMode: true }, onChange : function (editor) { editor.save(); } }); ``` Context: https://github.com/rsleggett/tridion-mirror/blob/master/src/BuildingBlocks.Tridion2011Extensions.CodeMirror/BuildingBlocks.Tridion2011Extensions.CodeMirror/Scripts/codemirror/codemirror.js I'm not sure what I'm missing. Any ideas?

Original source