diff --git a/CHANGELOG.md b/CHANGELOG.md index b176c6cb..c1d366d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### 🐛 Bug fixes +- Fixed issue where object boxes would be drawn on top of stack frames in diagrams with large left margins. + ### 📚 Documentation and demo website changes ### 🔧 Internal changes diff --git a/memory-viz/src/automate.ts b/memory-viz/src/automate.ts index 3e3e295b..9e368030 100644 --- a/memory-viz/src/automate.ts +++ b/memory-viz/src/automate.ts @@ -119,7 +119,7 @@ function drawAutomatedStackFrames(stack_frames: DrawnEntity[], configuration) { min_required_height = height + min_required_height; } - required_width += configuration.padding; + required_width += configuration.left_margin; return { StackFrames: draw_stack_frames, diff --git a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap index 93d5de5c..4bf5b5db 100644 --- a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap +++ b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap @@ -34,6 +34,8 @@ exports[`draw function renders a diagram with 'small' width value and a mix stac exports[`draw function renders a diagram with 'small' width value and no stack frames 1`] = `""David is cool!"id19str"`; +exports[`draw function renders a diagram with large left margins 1`] = `"aid7__main__xid1yid17funcid170id81id84list"David is cool!"id19str"`; + exports[`draw function renders a dict 1`] = `"idxidyidz:id81:id100:id121id10dict"`; exports[`draw function renders a float 1`] = `"7id32float"`; diff --git a/memory-viz/src/tests/draw.spec.tsx b/memory-viz/src/tests/draw.spec.tsx index 141c5a71..9d763461 100644 --- a/memory-viz/src/tests/draw.spec.tsx +++ b/memory-viz/src/tests/draw.spec.tsx @@ -848,4 +848,45 @@ describe("draw function", () => { const svg: String = m.serializeSVG(); expect(svg).toMatchSnapshot(); }); + + it("renders a diagram with large left margins", () => { + const objects: Array = [ + { + type: ".frame", + name: "__main__", + id: null, + value: { + a: 7, + }, + }, + { + type: ".frame", + name: "func", + id: null, + value: { + x: 1, + y: 17, + }, + }, + { + type: "list", + id: 84, + value: [17, 8], + show_indexes: true, + }, + { + type: "str", + id: 19, + value: "David is cool!", + style: ["highlight"], + }, + ]; + const m: InstanceType = draw(objects, true, { + width: 13, + left_margin: 150, + roughjs_config: { options: { seed: 12345 } }, + }); + const svg: String = m.serializeSVG(); + expect(svg).toMatchSnapshot(); + }); });