Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeMirror 2: Multiple indent is deleting lines

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?

like image 378
Rob Stevenson-Leggett Avatar asked May 21 '12 18:05

Rob Stevenson-Leggett


1 Answers

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.

like image 77
James Simm Avatar answered Oct 18 '22 08:10

James Simm