Skip to content

Inserting nothing in Pyret gives a parse error #3

@schanzer

Description

@schanzer

[From https://github.com/bootstrapworld/codemirror-blocks/issues/248]
Start with the code

f(x)

Now double-click on the drop target to one side of the x, and insert "" or " ".

This should be a no-op: you haven't inserted anything. Instead, it's a parse error. What happens is:

  1. A copy of the node f(x) is made.
  2. A new child is inserted into this node. This child is a fake node that prints itself out as " ", since that's what you inserted.
  3. The copied node is pretty-printed, producing f(x, ).
  4. The edit is thus taken to be: f(x) => f(x, ).
  5. Hence, parse error.

To fix this, I think we should add a check to see if text is purely whitespace in src/edits/performEdits/edit_insert(). If it is, skip the insert because nothing is being inserted.

TODO:

  • Fix this.
  • Think: will a similar problem plague any other kind of edit? If so, fix that too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions