@@ -33,10 +33,9 @@ import { NOTIFY_PROGRAM_EVALUATED } from '../sideContent/SideContentTypes';
33
33
import { SourceActionType } from '../utils/ActionsHelper' ;
34
34
import Constants from '../utils/Constants' ;
35
35
import { createContext } from '../utils/JsSlangHelper' ;
36
- import { browseReplHistoryDown } from './WorkspaceActions' ;
36
+ import { browseReplHistoryDown , browseReplHistoryUp } from './WorkspaceActions' ;
37
37
import {
38
38
ADD_EDITOR_TAB ,
39
- BROWSE_REPL_HISTORY_UP ,
40
39
CHANGE_EXEC_TIME ,
41
40
CHANGE_EXTERNAL_LIBRARY ,
42
41
CHANGE_SIDE_CONTENT_HEIGHT ,
@@ -128,7 +127,6 @@ export const WorkspaceReducer: Reducer<WorkspaceManagerState> = (
128
127
129
128
const newWorkspaceReducer = createReducer ( defaultWorkspaceManager , builder => {
130
129
builder
131
- . addCase ( 'TODO: REMOVE INDENTATION FIX' , ( state , action ) => { } )
132
130
. addCase ( browseReplHistoryDown , ( state , action ) => {
133
131
const workspaceLocation = getWorkspaceLocation ( action ) ;
134
132
if ( state [ workspaceLocation ] . replHistory . browseIndex === null ) {
@@ -156,62 +154,50 @@ const newWorkspaceReducer = createReducer(defaultWorkspaceManager, builder => {
156
154
records : newRecords ,
157
155
originalValue : ''
158
156
} ;
159
- } ) ;
160
- } ) ;
161
-
162
- const oldWorkspaceReducer : Reducer < WorkspaceManagerState > = (
163
- state = defaultWorkspaceManager ,
164
- action : SourceActionType
165
- ) => {
166
- const workspaceLocation = getWorkspaceLocation ( action ) ;
167
- let newOutput : InterpreterOutput [ ] ;
168
- let lastOutput : InterpreterOutput ;
169
-
170
- switch ( action . type ) {
171
- case BROWSE_REPL_HISTORY_UP :
157
+ } )
158
+ . addCase ( browseReplHistoryUp , ( state , action ) => {
159
+ const workspaceLocation = getWorkspaceLocation ( action ) ;
172
160
const lastRecords = state [ workspaceLocation ] . replHistory . records ;
173
161
const lastIndex = state [ workspaceLocation ] . replHistory . browseIndex ;
174
162
if (
175
163
lastRecords . length === 0 ||
176
164
( lastIndex !== null && lastRecords [ lastIndex + 1 ] === undefined )
177
165
) {
178
166
// There is no more later history to show
179
- return state ;
180
- } else if ( lastIndex === null ) {
167
+ return ;
168
+ }
169
+ if ( lastIndex === null ) {
181
170
// Not yet started browsing, initialise the index & array
182
171
const newIndex = 0 ;
183
172
const newRecords = lastRecords . slice ( ) ;
184
173
const originalValue = state [ workspaceLocation ] . replValue ;
185
174
const newReplValue = newRecords [ newIndex ] ;
186
- return {
187
- ...state ,
188
- [ workspaceLocation ] : {
189
- ...state [ workspaceLocation ] ,
190
- replValue : newReplValue ,
191
- replHistory : {
192
- ...state [ workspaceLocation ] . replHistory ,
193
- browseIndex : newIndex ,
194
- records : newRecords ,
195
- originalValue
196
- }
197
- }
198
- } ;
199
- } else {
200
- // Browsing history, and still have later history to show
201
- const newIndex = lastIndex + 1 ;
202
- const newReplValue = lastRecords [ newIndex ] ;
203
- return {
204
- ...state ,
205
- [ workspaceLocation ] : {
206
- ...state [ workspaceLocation ] ,
207
- replValue : newReplValue ,
208
- replHistory : {
209
- ...state [ workspaceLocation ] . replHistory ,
210
- browseIndex : newIndex
211
- }
212
- }
175
+
176
+ state [ workspaceLocation ] . replValue = newReplValue ;
177
+ state [ workspaceLocation ] . replHistory = {
178
+ browseIndex : newIndex ,
179
+ records : newRecords ,
180
+ originalValue
213
181
} ;
182
+ return ;
214
183
}
184
+ // Browsing history, and still have later history to show
185
+ const newIndex = lastIndex + 1 ;
186
+ const newReplValue = lastRecords [ newIndex ] ;
187
+ state [ workspaceLocation ] . replValue = newReplValue ;
188
+ state [ workspaceLocation ] . replHistory . browseIndex = newIndex ;
189
+ } ) ;
190
+ } ) ;
191
+
192
+ const oldWorkspaceReducer : Reducer < WorkspaceManagerState > = (
193
+ state = defaultWorkspaceManager ,
194
+ action : SourceActionType
195
+ ) => {
196
+ const workspaceLocation = getWorkspaceLocation ( action ) ;
197
+ let newOutput : InterpreterOutput [ ] ;
198
+ let lastOutput : InterpreterOutput ;
199
+
200
+ switch ( action . type ) {
215
201
case CHANGE_EXEC_TIME :
216
202
return {
217
203
...state ,
0 commit comments