CSCC - Common Sense Code Completion

What are the changes in the codemirror 0.67 core?

Note that the given line numbers reflect those in the original file. Not the cumulative ones after you've already made a change or two :)

In select.js, the insertAtCursor method has been made public. 
This is needed twice, because it has two browserdependant implementations.

  At line 303, insert:
    
    select.insertAtCursor = function(window, html) {
      insertAtCursor(window, html);
    };
    
  At line 543, insert:

    select.insertAtCursor = function(window, html) {
      insertNodeAtCursor(window, window.document.createTextNode(html));
    };


In editor.js, we add full control over keyboard events, and tweak a little indentation code.

  After line 706, insert:

    if (this.options.keyDownFunction) {
      var returnValue = this.options.keyDownFunction(event, select, this);
      if (!returnValue)
        return;
    }

  Replace line 729 to 731 with:

    // enter is pressed, so we want to know if we're the "|" here: <tag>|</tag>.
    var curPos = this.cursorPosition();
    var text = this.lineContent(curPos.line);
    var pos = curPos.character;
    var greaterThan = text.substr(pos - 1, 1);
    var smallerThanDash = text.substr(pos, 2);
    var isBetweenOpenTagAndCloseTag = greaterThan == ">" && smallerThanDash == "</";

    // if we are right between an open and closing tag, insert two newlines and properly indent
    if (isBetweenOpenTagAndCloseTag) {
      select.insertNewlineAtCursor(this.win);
      this.indentAtCursor();
      select.scrollToCursor(this.container);
      var curPos = this.cursorPosition();
      select.insertNewlineAtCursor(this.win);
      this.indentAtCursor();
      select.setCursorPos(this.container, { node: curPos.line, offset: curPos.character });
      this.indentAtCursor();
    }
    // otherwise, act normal
    else {
      select.insertNewlineAtCursor(this.win);
      this.indentAtCursor();
      select.scrollToCursor(this.container);
    }
      
  After line 811, insert:
  
    if (this.options.keyUpFunction) 
      this.options.keyUpFunction(event, select, this);

  After line 873, insert:
  
    return whiteSpace;
      
  Replace line 1081 to 1083 with:

    var lineStart = startOfLine(cursor);
    var whiteSpace = this.indentLineAfter(lineStart, direction);
    if (cursor == lineStart && whiteSpace)
      cursor = whiteSpace;
    // This means the indentation has probably messed up the cursor.
    if (cursor == whiteSpace)
      select.focusAfterNode(cursor, this.container);  