Skip to content

Commit d4eb7ae

Browse files
committed
Use variable for max repl history length
1 parent c6b0fdc commit d4eb7ae

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/components/__tests__/Playground.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const baseProps = {
2525
handleExternalSelect: (external: any, e: any) => {},
2626
handleGenerateLz: () => {},
2727
handleInterruptEval: () => {},
28-
handleLibrarySelect: (library: any, e: any) => {},
2928
handleReplEval: () => {},
3029
handleReplOutputClear: () => {},
3130
handleReplValueChange: (code: string) => {},

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
@@ -11,8 +11,10 @@ import {
1111
CLEAR_REPL_INPUT,
1212
CLEAR_REPL_OUTPUT,
1313
END_INTERRUPT_EXECUTION,
14+
EVAL_EDITOR,
1415
EVAL_INTERPRETER_ERROR,
1516
EVAL_INTERPRETER_SUCCESS,
17+
EVAL_REPL,
1618
HANDLE_CONSOLE_LOG,
1719
IAction,
1820
RESET_ASSESSMENT_WORKSPACE,
@@ -32,7 +34,8 @@ import {
3234
defaultComments,
3335
defaultWorkspaceManager,
3436
InterpreterOutput,
35-
IWorkspaceManagerState
37+
IWorkspaceManagerState,
38+
maxBrowseIndex
3639
} from './states'
3740

3841
/**
@@ -232,7 +235,7 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
232235
} else {
233236
newReplHistoryRecords = state[location].replHistory.records
234237
}
235-
if (newReplHistoryRecords.length > 50) {
238+
if (newReplHistoryRecords.length > maxBrowseIndex) {
236239
newReplHistoryRecords.pop()
237240
}
238241
return {
@@ -254,14 +257,6 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
254257
...state[location]
255258
}
256259
}
257-
case EVAL_REPL:
258-
// Forces re-render of workspace on repl eval
259-
return {
260-
...state,
261-
[location]: {
262-
...state[location]
263-
}
264-
}
265260
case EVAL_INTERPRETER_SUCCESS:
266261
lastOutput = state[location].output.slice(-1)[0]
267262
if (lastOutput !== undefined && lastOutput.type === 'running') {
@@ -306,6 +301,14 @@ export const reducer: Reducer<IWorkspaceManagerState> = (
306301
output: newOutput
307302
}
308303
}
304+
case EVAL_REPL:
305+
// Forces re-render of workspace on repl eval
306+
return {
307+
...state,
308+
[location]: {
309+
...state[location]
310+
}
311+
}
309312
/**
310313
* Called to signal the end of an interruption,
311314
* i.e called after the interpreter is told to stop interruption,

0 commit comments

Comments
 (0)