Skip to content

SurroundingRectangle too tall when surrounding code_lines #4376

@emilyrhee

Description

@emilyrhee

Description of bug / unexpected behavior

The first and third SurroundingRectangle in the image below is way taller than the second one. The issue of it being too tall seems to arise only when there is leading whitespace in a line of code.

Expected behavior

I expect every SurroundingRectangle to have the height of the one on line 5 of the image.

How to reproduce the issue

Code for reproducing the problem

Driver code:

from manim import *

class Test(Scene):
    def construct(self):
        code = Code("test.py", language="python")

        self.add(
            code, 
            SurroundingRectangle(code.code_lines[1]),
            SurroundingRectangle(code.code_lines[4]),
            SurroundingRectangle(code.code_lines[8])
        )

test.py:

def foo():
    print("bar")
    print("foobar")

def bar():
    print("foo")

for number in range(1, 9):
    print(number)

Additional media files

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions