Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/estepper-clear-unreachable-title-case.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sourceacademy/web-e-stepper": patch
---

e-stepper: the button is called "Clear Unreachable Objects", as in the CSE machine of the Source Academy frontend
4 changes: 2 additions & 2 deletions src/web/e-stepper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ for Python §3/§4), see the
read highlighted, and frames and objects that nothing refers to any more greyed out.
- When the host lends its CSE machine diagram (`ICseDiagramService` in `IHostServices`; the
Source Academy frontend does), the environments are drawn with it, as in the CSE machine, with
its toolbar (arrow filters, _Clear unreachable objects_). Each step carries its store as a CSE machine
its toolbar (arrow filters, _Clear Unreachable Objects_). Each step carries its store as a CSE machine
snapshot for it.
- Otherwise, the plugin draws them with its own Konva diagram (`EnvDiagram.tsx`), with the
options _From program_ (arrows from the program to the diagram) and _Clear unreachable objects_.
options _From program_ (arrows from the program to the diagram) and _Clear Unreachable Objects_.
- **Controls:** a slider (0 is the start of the evaluation); buttons for the first, previous,
next and last step; _Vertical_, which puts the program above the diagram instead of beside it.
The arrangement, and the divider between the panes, stay as the user left them over runs.
Expand Down
4 changes: 2 additions & 2 deletions src/web/e-stepper/src/EStepperView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default function EStepperView({ steps, profile, error, cseDiagram, layout
const [outputOpen, setOutputOpen] = useState(true);
// Display options. "From program" (all the arrows from the program to objects in the diagram) is on until the user turns it off; hovering still draws an arrow to its object or frame.
const [showArrows, setShowArrows] = useState(true);
// "Clear unreachable objects" lasts until the step changes, as in the CSE machine.
// "Clear Unreachable Objects" lasts until the step changes, as in the CSE machine.
const [clearUnreachable, setClearDead] = useState(false);
const [anchors, setAnchors] = useState<{
resolve: CseDiagramAnchorResolver | null;
Expand Down Expand Up @@ -529,7 +529,7 @@ export default function EStepperView({ steps, profile, error, cseDiagram, layout
<Button
icon="eraser"
style={{ marginLeft: 8 }}
text="Clear unreachable objects"
text="Clear Unreachable Objects"
disabled={
clearUnreachable ||
!(step?.frames.some(f => f.isGarbage) || step?.heap.some(o => o.isGarbage))
Expand Down
8 changes: 4 additions & 4 deletions src/web/e-stepper/src/__tests__/EStepperView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ describe("EStepperView", () => {
expect(view.root.findByType(ProgramArrows).props.all).toBe(false);
});

test("Clear unreachable objects is also available when only a heap object is unreachable", () => {
test("Clear Unreachable Objects is also available when only a heap object is unreachable", () => {
const onlyObject: EStepperStep = {
...fixture[2],
frames: fixture[2].frames.map(f => ({ ...f, isGarbage: false })),
Expand All @@ -594,15 +594,15 @@ describe("EStepperView", () => {
const view = render({ steps: [onlyObject], profile });
const clear = view.root
.findAllByType(Button)
.find(b => b.props.text === "Clear unreachable objects")!;
.find(b => b.props.text === "Clear Unreachable Objects")!;
expect(clear.props.disabled).toBe(false);
});

test("Clear unreachable objects clears them from the diagram until the step changes", () => {
test("Clear Unreachable Objects clears them from the diagram until the step changes", () => {
const view = render({ steps: fixture, profile });
const diagram = () => view.root.find(n => n.props.onAnchors && n.props.frames);
const clear = () =>
view.root.findAllByType(Button).find(b => b.props.text === "Clear unreachable objects")!;
view.root.findAllByType(Button).find(b => b.props.text === "Clear Unreachable Objects")!;
// Only the last step has unreachable frames (E2).
expect(clear().props.disabled).toBe(true);
act(() =>
Expand Down
Loading