Browse files

Solving the 'mixed tabs & spaces' warnings, by setting the codemirror…

… settings more the way they used to be.

Backstory: in CM 2.2, the handling of tabs changed. The setting
'tabMode' does no longer do anything, and by default, codemirror uses
a tab for indentation. That is why the warnings 'mixed tabs and spaces'
starts to show up from JSHint.

Now, there is no good way of disabling those warnings currently, and i
find having modified versions of libraries in the source rather awkward.

This commit restores the behavior of CodeMirror (to only use spaces for
indentation) back to the way it used to be before the CodeMirror
upgrade. I also tried to consider users with their own settings files,
who modified the tabMode option.
  • Loading branch information...
1 parent a5617fe commit 4c5974ec5e8382209d16f173816a0c69b6c35ff9 @karlwestin karlwestin committed with remy Jul 27, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 public/js/editors/panel.js
View
9 public/js/editors/panel.js
@@ -10,6 +10,12 @@ var editorModes = {
less: 'css'
};
+if(jsbin.settings.editor.tabMode === "default") {
+ CodeMirror.keyMap.basic.Tab = undefined;
+} else if(jsbin.settings.editor.tabMode !== "classic") {
+ CodeMirror.keyMap.basic.Tab = "indentMore";
+}
+
var Panel = function (name, settings) {
var panel = this,
showPanelButton = true,
@@ -53,7 +59,6 @@ var Panel = function (name, settings) {
if (settings.editor) {
cmSettings = {
parserfile: [],
- tabMode: 'shift',
readOnly: jsbin.state.embed ? 'nocursor' : false,
dragDrop: false, // we handle it ourselves
mode: editorModes[panelLanguage],
@@ -429,4 +434,4 @@ function populateEditor(editor, panel) {
if (changed) {
$document.trigger('codeChange', [ { revert: false, onload: true } ]);
}
-}
+}

0 comments on commit 4c5974e

Please sign in to comment.