@@ -17,6 +17,7 @@ import { getSettings, updateSettings } from '../react-common/settingsReactSide';
1717import  {  Cell ,  ICellViewModel  }  from  './cell' ; 
1818import  {  CellButton  }  from  './cellButton' ; 
1919import  {  Image ,  ImageName  }  from  './image' ; 
20+ import  {  InputHistory  }  from  './inputHistory' ; 
2021import  {  createCellVM ,  createEditableCellVM ,  generateTestState ,  IMainPanelState  }  from  './mainPanelState' ; 
2122import  {  MenuBar  }  from  './menuBar' ; 
2223
@@ -29,15 +30,14 @@ export interface IMainPanelProps {
2930
3031export  class  MainPanel  extends  React . Component < IMainPanelProps ,  IMainPanelState >  implements  IMessageHandler  { 
3132 private  stackLimit  =  10 ; 
32- 
3333 private  bottom : HTMLDivElement  |  undefined ; 
3434
3535 // tslint:disable-next-line:max-func-body-length 
3636 constructor ( props : IMainPanelProps ,  state : IMainPanelState )  { 
3737 super ( props ) ; 
3838
3939 // Default state should show a busy message 
40-  this . state  =  {  cellVMs : [ ] ,  busy : true ,  undoStack : [ ] ,  redoStack  : [ ] ,  historyStack :  [ ] ,   submittedText :  false } ; 
40+  this . state  =  {  cellVMs : [ ] ,  busy : true ,  undoStack : [ ] ,  redoStack  : [ ] ,  submittedText :  false ,   history :  new   InputHistory ( ) } ; 
4141
4242 // Add test state if necessary 
4343 if  ( ! this . props . skipDefault )  { 
@@ -205,7 +205,7 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
205205 return  this . state . cellVMs . map ( ( cellVM : ICellViewModel ,  index : number )  => 
206206 < ErrorBoundary  key = { index } > 
207207 < Cell 
208-  history = { cellVM . editable  ? this . state . historyStack  : [ ] } 
208+  history = { cellVM . editable  ? this . state . history  : undefined } 
209209 maxTextSize = { maxTextSize } 
210210 autoFocus = { document . hasFocus ( ) } 
211211 testMode = { this . props . testMode } 
@@ -628,17 +628,13 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
628628 // hide all inputs turned on. 
629629 editCell . directInput  =  true ; 
630630
631-  // Compute our new history (skip adding dupes) 
632-  const  newHistory  =  this . state . historyStack . indexOf ( code )  >=  0  ? this . state . historyStack  : [ code ,  ...this . state . historyStack ] ; 
633- 
634631 // Stick in a new cell at the bottom that's editable and update our state 
635632 // so that the last cell becomes busy 
636633 this . setState ( { 
637634 cellVMs : [ ...withoutEdits ,  editCell ,  createEditableCellVM ( this . getInputExecutionCount ( withoutEdits ) ) ] , 
638635 undoStack  : this . pushStack ( this . state . undoStack ,  this . state . cellVMs ) , 
639636 redoStack : this . state . redoStack , 
640637 skipNextScroll : false , 
641-  historyStack : newHistory , 
642638 submittedText : true 
643639 } ) ; 
644640
0 commit comments