Forráskód Böngészése

Merge pull request #1374 from R-Brain/code_editor_minor_fixes

Code editor minor fixes
Steven Silvester 8 éve
szülő
commit
2151392145

+ 5 - 0
src/codeeditor/editor.ts

@@ -24,6 +24,11 @@ import {
 
 /**
  * A namespace for code editors.
+ *
+ * #### Notes
+ * - A code editor is a set of common assumptions which hold for all concrete editors.
+ * - Changes in implementations of the code editor should only be caused by changes in concrete editors.
+ * - Common JLab services which are based on the code editor should belong to `IEditorServices`.
  */
 export
 namespace CodeEditor {

+ 3 - 3
src/codemirror/editor.ts

@@ -58,7 +58,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
   constructor(host: HTMLElement, options: CodeMirrorEditor.IOptions) {
     host.classList.add(EDITOR_CLASS);
     this.uuid = this.uuid;
-    this.selectionStyle = this.selectionStyle;
+    this.selectionStyle = options.selectionStyle;
 
     this._model = new CodeMirrorModel();
 
@@ -245,7 +245,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
   getSelections(): CodeEditor.ITextSelection[] {
     const selections = this._model.doc.listSelections();
     if (selections.length > 0) {
-      return this._model.doc.listSelections().map(selection => this.toSelection(selection));
+      return selections.map(selection => this.toSelection(selection));
     }
     const cursor = this._model.doc.getCursor();
     const selection = this.toSelection({ anchor: cursor, head: cursor });
@@ -334,7 +334,7 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
   }
 
   /**
-   * Converts a code mirror selectio to an editor selection.
+   * Converts a code mirror selection to an editor selection.
    */
   protected toSelection(selection: CodeMirror.Selection): CodeEditor.ITextSelection {
     return {

+ 3 - 0
src/codemirror/index.ts

@@ -1,3 +1,6 @@
+// Copyright (c) Jupyter Development Team.
+// Distributed under the terms of the Modified BSD License.
+
 export * from './mode';
 export * from './model';
 export * from './editor';

+ 4 - 1
src/codemirror/model.ts

@@ -21,7 +21,7 @@ import {
  * An implementation of the code editor model using code mirror.
  */
 export
-  class CodeMirrorModel implements CodeEditor.IModel {
+class CodeMirrorModel implements CodeEditor.IModel {
 
   /**
    * A signal emitted when a content of the model changed.
@@ -49,6 +49,9 @@ export
     });
   }
 
+  /**
+   * An underying CodeMirror document.
+   */
   get doc(): CodeMirror.Doc {
     return this._doc;
   }