From 6075916ef18dc4a8cbea41c941d2d0b519360262 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Tue, 26 Jun 2012 13:04:04 -0700 Subject: fixed code hinting and autocompletion bug Signed-off-by: Ananya Sen --- js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js | 4 ++-- .../ui/code-editor-view-options.reel/code-editor-view-options.css | 5 +++++ .../code-editor-view-options.reel/code-editor-view-options.html | 2 +- .../ui/code-editor-view-options.reel/code-editor-view-options.js | 8 ++++++++ js/controllers/code-editor-controller.js | 5 ++++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js index 4787b4f8..adcafd41 100644 --- a/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js +++ b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js @@ -22,8 +22,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot function insert(str) { editor.replaceRange(str, result.from, result.to); } - // Ninja override: don't autocomplete to reduce user's typing errors -// if (completions.length == 1) {insert(completions[0]); return true;} + + if (completions.length == 1) {insert(completions[0]); return true;} // Build the select widget var complete = document.createElement("div"); diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css index aeaf604c..68d77f90 100644 --- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css +++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css @@ -22,6 +22,11 @@ vertical-align: middle; } +.viewOptions .autoCodeComplete input{ + width: 1em; + height: 1em; +} + .viewOptions .autoCodeComplete .disabled{ color:#515151; } diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html index 4448e1f1..3d5df256 100644 --- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html +++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html @@ -54,7 +54,7 @@
- +
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js index 13c9a705..04b509a6 100644 --- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js +++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js @@ -121,6 +121,12 @@ exports.CodeEditorViewOptions = Montage.create(Component, { oneway : false }); + Object.defineBinding(this.codeCompleteCheck , "checked", { + boundObject: this.application.ninja.codeEditorController, + boundObjectPropertyPath: "automaticCodeComplete", + oneway : false + }); + } }, @@ -137,6 +143,8 @@ exports.CodeEditorViewOptions = Montage.create(Component, { } else { this.autoCompleteLabel.classList.remove("disabled"); } + + this.codeCompleteCheck.checked = false; } }, diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js index f3c19b92..4572d69a 100644 --- a/js/controllers/code-editor-controller.js +++ b/js/controllers/code-editor-controller.js @@ -32,7 +32,7 @@ exports.CodeEditorController = Montage.create(Component, { if(!value) { } else if(this._currentDocument.currentView === "code") { - this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension]; + this.autocomplete = this.codeCompletionSupport[this._currentDocument.model.file.extension]; this._currentDocument.model.views.code.editor.focus(); this.applySettings(); } @@ -132,6 +132,9 @@ exports.CodeEditorController = Montage.create(Component, { }; //configure auto code completion if it is supported for that document type + + this.autocomplete = this.codeCompletionSupport[documentType]; + if(this.autocomplete) { editorOptions.onKeyEvent = function(cm, keyEvent){ -- cgit v1.2.3