Переглянути джерело

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);
   }
 
   /**