Skip to content

MarkdownComponent: NotImplementedError in certain edge cases with blank markdown #98

@DJtheRedstoner

Description

@DJtheRedstoner

Describe the bug
In certain cases, the a MarkdownComponent can have 0 drawables, which causes a NotImplementedError here.

To Reproduce
Steps to reproduce the behavior:

  1. Apply this patch to ComponentsGui
@@ -267,7 +268,7 @@
         } childOf window
 
         ComponentType("Markdown") {
-            MarkdownComponent(
+            val c = MarkdownComponent(
                 """
                     # Markdown!
                     
@@ -283,6 +284,11 @@
                 width = 200.pixels()
                 height = 100.pixels()
             } childOf this
+
+            c.onMouseClick {
+                c.bindText(BasicState(""))
+            }
+
         } childOf window
 
         ComponentType("SVG") {
  1. Open the components gui
  2. Click on the current text of the markdown component, hold and drag to another location on the screen
  3. The gui crashes and a NotImplementedError is logged (example)

Expected behavior
The the markdown component becomes blank without crashing the gui.

Additional context
There are possibly other ways to trigger this issue, but this is the way I found. The root cause appears to be commonmark's parser not having any children nodes for a blank document, causing MarkdownRenderer to produce an empty drawable list

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions