浏览代码

Fix console new line behaviour

Fixes #1280 - line breaks are now inserted at the cursor, rather than at
the end of the cell.
mridsole 8 年之前
父节点
当前提交
ea7cbe6c16
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/console/content.ts

+ 5 - 2
src/console/content.ts

@@ -315,8 +315,11 @@ class ConsoleContent extends Widget {
   insertLinebreak(): void {
     let prompt = this.prompt;
     let model = prompt.model;
-    model.source += '\n';
-    prompt.editor.setCursorPosition(model.source.length);
+    // Insert the line break at the cursor position, and move cursor forward.
+    let pos = prompt.editor.getCursorPosition();
+    model.source = model.source.substr(0, pos) + '\n' +
+      model.source.substr(pos);
+    prompt.editor.setCursorPosition(pos + 1);
   }
 
   /**