浏览代码

[notebook] Set correct ace mode for new snippets

For each snippet that has an ace editor we should specify the mode for autocompletion and syntax highlighting to work.
Johan Ahlen 10 年之前
父节点
当前提交
cbe84c7

+ 5 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete.js

@@ -36,7 +36,11 @@ function Autocompleter(options) {
   }
 
   huePubSub.subscribe('hue.ace.activeMode', function(mode) {
-    self.currentMode = mode.split("/").pop();
+    if (mode) {
+      self.currentMode = mode.split("/").pop();
+    } else {
+      self.currentMode = null;
+    }
   })
 }
 

+ 5 - 3
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -101,10 +101,12 @@ var Result = function (snippet, result) {
 var TYPE_ACE_EDITOR_MAP = {
   'hive': 'ace/mode/hive',
   'impala': 'ace/mode/impala',
-  'pyspark': 'ace/mode/python',
-  'spark': 'ace/mode/scala',
+  'mysql': 'ace/mode/sql',
+  'mysqljdbc': 'ace/mode/sql',
   'pig': 'ace/mode/pig',
-  'r': 'ace/mode/r'
+  'pyspark': 'ace/mode/python',
+  'r': 'ace/mode/r',
+  'scala': 'ace/mode/scala'
 };
 
 var getDefaultSnippetProperties = function (snippetType) {