Skip to content

Code highlighting problem #113

Closed
Closed
@daniasuheimat

Description

@daniasuheimat

Bug Description

Code structure highlighting disappears in the "elif" block of an if statement.

How To Reproduce

Steps to reproduce the behavior:

  1. Example code: https://microbit.org/projects/make-it-code-it/magic-8ball/?editor=python
  2. Paste the code up until the second if statement:
    image
  3. Add a few blank lines after:
    image
  4. Go back to the end of the last non-empty line, press enter to go to a new line, and type "elif". It should still be highlighted at this stage:
    image
  5. Press space right after the "elif":
    image

Parsed tree (logged to Console with its toString() method) before adding the elif and pressing space:
blocks.ts:97 Script(Comment,ImportStatement(import,VariableName),WhileStatement(while,Boolean,Body(":",IfStatement(if,CallExpression(MemberExpression(VariableName,".",PropertyName),ArgList("(",String,")")),Body(":",AssignStatement(VariableName,AssignOp,CallExpression(MemberExpression(VariableName,".",PropertyName),ArgList("(",Number,",",Number,")"))),IfStatement(if,BinaryExpression(VariableName,CompareOp,Number),Body(":",ExpressionStatement(CallExpression(MemberExpression(VariableName,".",PropertyName),ArgList("(",MemberExpression(VariableName,".",PropertyName),")"))))))))))

After:
Script(Comment,ImportStatement(import,VariableName),WhileStatement(while,Boolean,Body(":",IfStatement(if,CallExpression(MemberExpression(VariableName,".",PropertyName),ArgList("(",String,")")),Body(":",AssignStatement(VariableName,AssignOp,CallExpression(MemberExpression(VariableName,".",PropertyName),ArgList("(",Number,",",Number,")"))),IfStatement(if,BinaryExpression(VariableName,CompareOp,Number),Body(":",ExpressionStatement(CallExpression(MemberExpression(VariableName,".",PropertyName),ArgList("(",MemberExpression(VariableName,".",PropertyName),")"))),⚠)),⚠)),⚠)),⚠(elif))

Expected behavior

The "elif" and what follows are meant to be highlighted as well.

Status

We simplified this a bit and raised codemirror/dev#487

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