Skip to content

Commit e196a8c

Browse files
committed
Use variable for max repl history length
1 parent 31c76dc commit e196a8c

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/reducers/states.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ type ReplHistory = {
7171
records: string[]
7272
}
7373

74+
export const maxBrowseIndex = 50
75+
7476
/**
7577
* An output while the program is still being run in the interpreter. As a
7678
* result, there are no return values or SourceErrors yet. However, there could

src/reducers/workspaces.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import {
1212
CLEAR_REPL_INPUT,
1313
CLEAR_REPL_OUTPUT,
1414
END_INTERRUPT_EXECUTION,
15+
EVAL_EDITOR,
1516
EVAL_INTERPRETER_ERROR,
1617
EVAL_INTERPRETER_SUCCESS,
18+
EVAL_REPL,
1719
HANDLE_CONSOLE_LOG,
1820
IAction,
1921
RESET_ASSESSMENT_WORKSPACE,
@@ -34,7 +36,8 @@ import {
3436
defaultWorkspaceManager,
3537
externalLibraries,
3638
InterpreterOutput,
37-
IWorkspaceManagerState
39+
IWorkspaceManagerState,
40+
maxBrowseIndex
3841
} from './states'
3942

4043
/**
@@ -257,7 +260,7 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
257260
} else {
258261
newReplHistoryRecords = state[location].replHistory.records
259262
}
260-
if (newReplHistoryRecords.length > 50) {
263+
if (newReplHistoryRecords.length > maxBrowseIndex) {
261264
newReplHistoryRecords.pop()
262265
}
263266
return {
@@ -279,14 +282,6 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
279282
...state[location]
280283
}
281284
}
282-
case EVAL_REPL:
283-
// Forces re-render of workspace on repl eval
284-
return {
285-
...state,
286-
[location]: {
287-
...state[location]
288-
}
289-
}
290285
case EVAL_INTERPRETER_SUCCESS:
291286
lastOutput = state[location].output.slice(-1)[0]
292287
if (lastOutput !== undefined && lastOutput.type === 'running') {
@@ -336,6 +331,14 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
336331
* i.e called after the interpreter is told to stop interruption,
337332
* to cause UI changes.
338333
*/
334+
case EVAL_REPL:
335+
// Forces re-render of workspace on repl eval
336+
return {
337+
...state,
338+
[location]: {
339+
...state[location]
340+
}
341+
}
339342
case END_INTERRUPT_EXECUTION:
340343
/**
341344
* Set the isRunning property of the

0 commit comments

Comments
 (0)