浏览代码

Merge pull request #2170 from ellisonbg/console-clear

Console clear
Steven Silvester 8 年之前
父节点
当前提交
558ea12a94
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      packages/console/src/widget.ts

+ 8 - 1
packages/console/src/widget.ts

@@ -455,7 +455,14 @@ class CodeConsole extends Widget {
    * Execute the code in the current prompt cell.
    */
   private _execute(cell: CodeCell): Promise<void> {
-    this._history.push(cell.model.value.text);
+    let source = cell.model.value.text;
+    this._history.push(source);
+    // If the source of the console is just "clear", clear the console as we
+    // do in IPython or QtConsole.
+    if ( source === 'clear' || source === '%clear' ) {
+      this.clear();
+      return Promise.resolve(void 0)
+    }
     cell.model.contentChanged.connect(this.update, this);
     let onSuccess = (value: KernelMessage.IExecuteReplyMsg) => {
       if (this.isDisposed) {