Skip to content

Commit e6f1cbe

Browse files
committed
Fix line explanation bug (hack)
Probably should be fixed in a better way but...
1 parent f83c3aa commit e6f1cbe

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/algorithms/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,21 @@ import * as Instructions from './instructions';
2727
{ pseudocode: String, explanation: String, run: Function }
2828
*/
2929

30-
// Very Important: The key for the algorithms must be unique!
30+
// Very Important: The key for each algorithm MUST be unique!
31+
// Also: the key for the algorithm MUST be the same as the "name"
32+
// of the top level Param block returned by the parameter function.
33+
// Eg, parameters/msort_arr_td.js has
34+
//
35+
// function MergesortParam() {
36+
// ...
37+
// return (
38+
// // <>
39+
// <div className="form">
40+
// <ListParam
41+
// name="msort_arr_td" <---- ****SAME AS KEY****
42+
// ...
43+
// export default MergesortParam
44+
3145
const allalgs = {
3246

3347
'heapSort': {

src/context/actions.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,13 @@ export const GlobalActions = {
253253
} = data;
254254
const procedurePseudocode = pseudocode[params.mode];
255255

256+
// Previously if we switched modes from insert to search, the search
257+
// code had no in-line explanations built.
258+
// XXX It seems a bit of overkill to redo the explanations whenever
259+
// the algorithm is re-run (changing mode probable should LOAD the
260+
// algorithm then separately RUN it) but this works for now...
261+
addLineExplanation(procedurePseudocode);
262+
256263
// here we pass a function reference to Chunker() because we may want to initialise
257264
// a visualiser using a previous one
258265
const chunker = new Chunker(() =>

0 commit comments

Comments
 (0)