瀏覽代碼

Use history placeholder to store temporary value of prompt when navigating history.

Afshin Darian 8 年之前
父節點
當前提交
69245442b1
共有 1 個文件被更改,包括 12 次插入4 次删除
  1. 12 4
      src/console/content.ts

+ 12 - 4
src/console/content.ts

@@ -383,17 +383,24 @@ class ConsoleContent extends Widget {
   protected onEdgeRequest(editor: ICellEditorWidget, location: EdgeLocation): void {
     let prompt = this.prompt;
     if (location === 'top') {
-      this._history.back().then(value => {
+      this._history.back(prompt.model.source).then(value => {
         if (!value) {
           return;
         }
+        if (prompt.model.source === value) {
+          return;
+        }
+        this._setByHistory = true;
         prompt.model.source = value;
         prompt.editor.setCursorPosition(0);
       });
     } else {
-      this._history.forward().then(value => {
-        // If at the bottom end of history, then clear the prompt.
-        let text = value || '';
+      this._history.forward(prompt.model.source).then(value => {
+        let text = value || this._history.placeholder;
+        if (prompt.model.source === text) {
+          return;
+        }
+        this._setByHistory = true;
         prompt.model.source = text;
         prompt.editor.setCursorPosition(text.length);
       });
@@ -552,6 +559,7 @@ class ConsoleContent extends Widget {
   private _renderer: ConsoleContent.IRenderer = null;
   private _history: IConsoleHistory = null;
   private _session: ISession = null;
+  private _setByHistory = false;
   private _foreignCells: { [key: string]: CodeCellWidget; } = {};
 }