Skip to content

Sequence diagram requires colon and whitespace : after an arrow without label #6518

@amatiasq

Description

@amatiasq

Description

When we want to create an arrow without a label:

sequenceDiagram
A ->> B: A calls B
%% ❌ Expecting 'TXT' got 'NEWLINE'
B ->> A

It crashes because it expects the colon at the end, but this doesn't work either

sequenceDiagram
A ->> B: A calls B
%% ❌ Expecting 'NEWLINE', 'AS', ',', 'SOLID_OPEN_ARROW', ... got 'INVALID'
B ->> A:

It only works after I add a blank space after the colon

sequenceDiagram
A ->> B: A calls B
%%
B ->> A: 
%%      ⬆︎ invisible trailing whitespace at the end

We don't understand what makes the colon is required in the first place, but even if it is, why is the trailing whitespace mandatory?

We have our editors configured to remove trailing whitespace for code hygiene, but applying this to sequence diagrams leaves them broken, we either disable this from our editors or add an exception for Mermaid files.

Steps to reproduce

  1. Create an sequence diagram
  2. Create an arrow without a label

Screenshots

This is the wanted result.

Image

Adding a label to the second arrow separates them.

Image

Code Sample

sequenceDiagram
A ->> B: A calls B
B ->> A:

Setup

Mermaid version:

VS Code extension version 2.2.1.

Also reproducible in Github mermaid preview.

Suggested Solutions

  • Not require whitespace after ':'
  • Not require ':' for all arrows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageNeeds to be verified, categorized, etcType: Bug / ErrorSomething isn't working or is incorrect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions