Merge branch 'ZEPPELIN-277' of github.com:malayhm/zeppelin into ZEPPELIN-277

# Conflicts:
#	zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
This commit is contained in:
Malay Majithia 2017-10-10 18:04:40 +05:30
commit 63d69e1c0c
4 changed files with 32 additions and 8 deletions

View file

@ -74,7 +74,8 @@ Here is an example of `interpreter-setting.json` on your own interpreter.
},
"editor": {
"language": "your-syntax-highlight-language",
"editOnDblClick": false
"editOnDblClick": false,
"completionKey": "TAB"
}
},
{
@ -128,6 +129,19 @@ If your interpreter uses mark-up language such as markdown or HTML, set `editOnD
"editOnDblClick": false
}
```
### Completion key (Optional)
By default, `Ctrl+dot(.)` brings autocompletion list in the editor.
Through `completionKey`, each interpreter can configure autocompletion key.
Currently `TAB` is only available option.
```
"editor": {
"completionKey": "TAB"
}
```
## Install your interpreter binary
Once you have built your interpreter, you can place it under the interpreter directory with all its dependencies.

View file

@ -44,7 +44,8 @@
},
"editor": {
"language": "python",
"editOnDblClick": false
"editOnDblClick": false,
"completionKey": "TAB"
}
},
{

View file

@ -71,7 +71,8 @@
},
"editor": {
"language": "scala",
"editOnDblClick": false
"editOnDblClick": false,
"completionKey": "TAB"
}
},
{
@ -110,7 +111,8 @@
},
"editor": {
"language": "sql",
"editOnDblClick": false
"editOnDblClick": false,
"completionKey": "TAB"
}
},
{
@ -135,7 +137,8 @@
},
"editor": {
"language": "scala",
"editOnDblClick": false
"editOnDblClick": false,
"completionKey": "TAB"
}
},
{
@ -160,7 +163,8 @@
},
"editor": {
"language": "python",
"editOnDblClick": false
"editOnDblClick": false,
"completionKey": "TAB"
}
},
{

View file

@ -185,6 +185,11 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca
}
}
const isTabCompletion = function() {
const completionKey = $scope.paragraph.config.editorSetting.completionKey
return completionKey === 'TAB'
}
$scope.$on('updateParagraphOutput', function (event, data) {
if ($scope.paragraph.id === data.paragraphId) {
if (!$scope.paragraph.results) {
@ -870,9 +875,9 @@ function ParagraphCtrl ($scope, $rootScope, $route, $window, $routeParams, $loca
let currentLine = $scope.editor.session.getLine(iCursor.row)
let isAllTabs = currentLine.substring(0, iCursor.column - 1).split('').every(function(char) { return (char === '\t' || char === ' ') })
// If user has pressed tab on first line char or if editor mode is %md, keep existing behavior
// If user has pressed tab on first line char or if isTabCompletion() is false, keep existing behavior
// If user has pressed tab anywhere in between and editor mode is not %md, show autocomplete
if (!isAllTabs && iCursor.column && $scope.paragraph.config.editorMode !== 'ace/mode/markdown') {
if (!isAllTabs && iCursor.column && isTabCompletion()) {
$scope.editor.execCommand('startAutocomplete')
} else {
ace.config.loadModule('ace/ext/language_tools', function () {