浏览代码

Indent using editor when running unforced

Saul Shanabrook 7 年之前
父节点
当前提交
e12fcbec34
共有 1 个文件被更改,包括 3 次插入7 次删除
  1. 3 7
      packages/console/src/widget.ts

+ 3 - 7
packages/console/src/widget.ts

@@ -292,6 +292,8 @@ class CodeConsole extends Widget {
       return this._execute(promptCell);
     }
 
+    // Add a new line and indent it before seeing if we can execute
+    promptCell.editor.newIndentedLine();
     // Check whether we should execute.
     return this._shouldExecute(timeout).then(should => {
       if (this.isDisposed) {
@@ -573,7 +575,7 @@ class CodeConsole extends Widget {
       return Promise.resolve(false);
     }
     let model = promptCell.model;
-    let code = model.value.text + '\n';
+    let code = model.value.text;
     return new Promise<boolean>((resolve, reject) => {
       let timer = setTimeout(() => { resolve(true); }, timeout);
       let kernel = this.session.kernel;
@@ -590,12 +592,6 @@ class CodeConsole extends Widget {
           resolve(true);
           return;
         }
-        model.value.text = code + isComplete.content.indent;
-        let editor = promptCell.editor;
-        let pos = editor.getPositionAt(model.value.text.length);
-        if (pos) {
-          editor.setCursorPosition(pos);
-        }
         resolve(false);
       }).catch(() => { resolve(true); });
     });